申请 申请计划
我在这里缺少什么?我在Scheme中玩apply
,并写道:
(apply apply '(+ (1 2 3)))
据我理解,第一个apply应该做:
(apply + '(1 2 3))
第二个应该做:
(+ 1 2 3)
但是Ypsilon和Gauche都给出了相同的错误(这是Ypsilon的) ):
error: attempt call non-procedure: (+ 1 2 3)
backtrace:
0 (apply apply '(+ (1 2 3)))
..."/dev/stdin" line 1
我有什么不明白的地方?
What am I missing here? I was playing with apply
in Scheme, and wrote:
(apply apply '(+ (1 2 3)))
The way I understand it, the first apply should do:
(apply + '(1 2 3))
and the second should do:
(+ 1 2 3)
But both Ypsilon and Gauche give about the same error (this is Ypsilon's):
error: attempt call non-procedure: (+ 1 2 3)
backtrace:
0 (apply apply '(+ (1 2 3)))
..."/dev/stdin" line 1
What have I failed to understand?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
'(+ (1 2 3))
的问题在于+
被引用,因此被解释为符号。您必须使用
eval
来获取+
符号的值。换句话说,你试图做的事情是行不通的。
编辑:另一个选择是准引用。例如:
或者(不带准引号)
The problem with
'(+ (1 2 3))
is that the+
is quoted and thus interpreted as a symbol.You would have to use
eval
to get a value for the+
symbol.In other words, what you are trying to do, is not going to work.
Edit: Another option is quasiquote. Eg:
Or (without quasiquote)