【问题标题】:Filtering an expression output with regexp使用正则表达式过滤表达式输出
【发布时间】:2020-04-21 10:42:35
【问题描述】:

main的错误代码是(string-match "module" (help uri-path)),它返回一个错误

scheme@(guile-user) [5]> (string-match "module" (help uri-path))
`uri-path' is an object in the (web uri) module.

- Special Form: uri-path

While compiling expression:
Syntax error:
unknown file:9:23: sequence of zero expressions in form (begin)
scheme@(guile-user) [5]>

我想要达到的是只显示一行帮助功能输出。如何解决?

【问题讨论】:

  • help打印帮助,而不是作为字符串返回。您必须了解 help 的实现才能以某种方式将输出捕获为字符串。

标签: scheme read-eval-print-loop guile


【解决方案1】:

使用procedure-documentation 以字符串形式获取过程的文档。

scheme@(guile-user)> (help cons)
`cons' is a procedure in the (ice-9 safe-r5rs) module.

- Scheme Procedure: cons x y
     Return a newly allocated pair whose car is X and whose cdr is Y.
     The pair is guaranteed to be different (in the sense of `eq?') from
     every previously existing object.
scheme@(guile-user)> (procedure-documentation cons)
$6 = "- Scheme Procedure: cons x y\n     Return a newly allocated pair whose car is X and whose cdr is Y.\n     The pair is guaranteed to be different (in the sense of `eq?') from\n     every previously existing object."

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    相关资源
    最近更新 更多