【问题标题】:Function call error Scheme函数调用错误方案
【发布时间】:2017-09-11 04:59:33
【问题描述】:

我正在使用https://repl.it/languages/scheme 编译我的Scheme 代码,但遇到了一些函数调用错误。函数是:

 (define (bloop x)
      (cond
        ((null? x) 0)
        ((not (list? (car x))) 
            (+ 1 (bloop (cdr x))))
        ((eq? x ’()) (bloop (car x)))))

我想传递类似的东西:

(bloop '((1) 2 3 4))

但我明白了:

Error: execute: unbound symbol: "’"

欢迎提出任何意见、问题或疑虑。

【问题讨论】:

  • bloop 的几个点: 1. (null? x)(eq? x '()) 检查相同的东西; 2. cond 在某些(大多数?)方案实现中需要有else 子句。 3.如果x是一个数字怎么办?

标签: scheme


【解决方案1】:

排队:

((eq? x ’()) (bloop (car x)))))

符号不是 ASCII 引号 '

PS。在 Scheme 行话中,bloop 是一个过程Function 是数学的东西,比如“sin(x)”,但(sin x) 是实现这个函数的过程。

【讨论】:

  • 我看到琵琶方案使用“功能”来表示“程序”。异端! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多