【问题标题】:scheme format function missing from gambit策略中缺少方案格式功能
【发布时间】:2018-05-12 16:01:59
【问题描述】:

我尝试运行之前使用 guile 运行的策略方案脚本。我注意到 gambit 失败了,因为它缺少“格式”功能。

格式不是方案的一部分吗?

(format #t "example(~a)=<~a>\n" i (example i))

相反,我将 gambit 脚本修改为以下内容。

(display (string-append "example(" (number->string i) ")=<" (number->string (example i)) ">\n"))

我在这里缺少什么?谢谢。

【问题讨论】:

  • 它不是任何 Scheme 标准的一部分。 SRFI 28 中也有类似的设施。

标签: scheme guile gambit


【解决方案1】:

在 Gambit 中你可以使用标准的 R7RS 库,你需要导入包含格式函数的 SRFI-28。

(import (srfi 28))

但是 SRFI-28 定义的 Scheme 格式函数没有像 Common Lips 那样打印到标准输出的 #t 参数。第一个参数始终是输出字符串模式:

(display (format "example(~a)=<~a>\n" i (example i)))
(newline)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-21
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多