4

我从鸡肉计划开始。下面的代码适用于 mit-scheme repl,但不适用于 csi。csi 在文档中定义了过滤器,但是当我运行下面的代码时出现未绑定变量错误。

    CHICKEN
(c) 2008-2015, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.10.0 (rev b259631)
macosx-unix-clang-x86-64 [ 64bit manyargs dload ptables ]
compiled 2015-08-04 on yves.more-magic.net (Linux)

#;1> (filter odd? '(1 2 3 ))

Error: unbound variable: filter

    Call history:

    <syntax>          (filter odd? (quote (1 2 3)))
    <syntax>          (quote (1 2 3))
    <syntax>          (##core#quote (1 2 3))
    <eval>    (filter odd? (quote (1 2 3))) <--
#;1>
4

2 回答 2

4

不确定filter您指的是哪个程序,但似乎filter文档中列出的程序之一仅在宏扩展期间可用:

http://api.call-cc.org/doc/bindings#sec:filter

您可以在运行时使用的定义在 SRFI-1 库中。要使用它,您只需添加以下内容:

(use srfi-1)

于 2015-09-07T06:50:21.517 回答
4

filter是在模块中定义srfi-1,因此您必须首先加载该模块以使其可用:

CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0.1 (stability/4.9.0) (rev 8b3189b)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
bootstrapped 2014-06-07

#;1> (use srfi-1)
; loading /var/lib//chicken/7/srfi-1.import.so ...
; loading library srfi-1 ...
#;2> (filter odd? '(1 2 3 ))
(1 3)
#;3>
于 2015-09-07T06:51:56.263 回答