lisp - lisp"不知道如何创建 ISeq: 在Clojure中,符号"错误

  显示原文与译文双语对照的内容

我有以下的Clojure代码,我不确定为什么它不能正常工作:


(defn match (x y &optional binds)


 (cond


 ((eql x y) (values binds t))


 ((assoc x binds) (match (binding x binds) y binds))


 ((assoc y binds) (match x (binding y binds) binds))


 ((var? x) (values (cons (cons x y) binds) t))


 ((var? y) (values (cons (cons y x) binds) t))


 (t


 (when (and (consp x) (consp y))


 (multiple-value-bind (b2 yes)


 (match (car x) (car y) binds)


 (and yes (match (cdr x) (cdr y) b2)))))))



( 代码由graham通用 Lisp 书的Paul 翻译。)

运行它时,会出现以下错误:


java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol


clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:2: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol


 at clojure.lang.Compiler.analyze(Compiler.java:3713)


 at clojure.lang.Compiler.analyzeSeq(Compiler.java:3848)


 at clojure.lang.Compiler.analyze(Compiler.java:3698)


 at clojure.lang.Compiler.access$200(Compiler.java:37)


 at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:343)


 at clojure.lang.Compiler.analyzeSeq(Compiler.java:3858)


 at clojure.lang.Compiler.analyze(Compiler.java:3698)


 at clojure.lang.Compiler.analyzeSeq(Compiler.java:3848)


 at clojure.lang.Compiler.analyze(Compiler.java:3698)


 at clojure.lang.Compiler.analyze(Compiler.java:3671)


 at clojure.lang.Compiler.eval(Compiler.java:3895)


 at clojure.lang.Repl.main(Repl.java:75)


 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)


 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


 at java.lang.reflect.Method.invoke(Unknown Source)


 at jline.ConsoleRunner.main(ConsoleRunner.java:69)


Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol


 at clojure.lang.LazyCons.rest(LazyCons.java:64)


 at clojure.lang.ASeq.count(ASeq.java:85)


 at clojure.lang.RT.count(RT.java:486)


 at clojure.lang.Cons.count(Cons.java:41)


 at clojure.lang.Compiler.analyze(Compiler.java:3695)


. . . 16 more


Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol


 at clojure.lang.LazyCons.first(LazyCons.java:44)


 at clojure.lang.LazyCons.rest(LazyCons.java:59)


. . . 20 more


Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol


 at clojure.lang.RT.seqFrom(RT.java:465)


 at clojure.lang.RT.seq(RT.java:448)


 at clojure.seq__28.invoke(boot.clj:92)


 at clojure.every_QMARK___596.invoke(boot.clj:1180)


 at clojure.fn__1147$psig__1149.invoke(boot.clj:2155)


 at clojure.map__602$fn__605.invoke(boot.clj:1214)


 at clojure.lang.LazyCons.first(LazyCons.java:40)


. . . 21 more



我 在 这儿 写错 了 吗?

时间: 原作者:

问题是,我使用括号('('还有')'),而不是方括号('['and']'),用于参数列表。

它应该像这样开始:


(defn match [x y &optional binds]



( 我在编程中找到了answer编程的答案,Stuart 。

原作者:
...