"Don't know how to create ISeq from: Symbol" error in Clojure
Solution 1
The problem is that I'm using parentheses ('(' and ')'), rather than square brackets ('[' and ']'), for the arguments list.
It should start out like this:
(defn match [x y &optional binds]
(I found the answer in Programming Clojure by Stuart Halloway.)
Solution 2
Also, the cond form doesn't use parens for its clauses:
(cond
test1 eval1
test2 eval2
:else eval3)
Solution 3
The main answer was already given (function arguments are in [] not () in clojure) but before trying to mess with code from Common Lisp sources, I'd recommend actually learning Clojure's syntax, as it is NOT anything close to a pure CL port, at all. You're just going to get into trouble treating it like it is.
Solution 4
This seems to be a symptom for various syntax errors.
I've had it when accidentally writing a .
after the docstring, i.e. "bla bla".
instead of "bla bla."
. It was rather hard to find, because the line number in the error message was incorrect.
JanusFox81
I am interested in functional programming. I am also interested in music programming, such as in ChucK or impromptu. My favorite language is Lisp.
Updated on June 03, 2022Comments
-
JanusFox81 almost 2 years
I have the following Clojure code and I'm not sure why it's not working:
(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)))))))
(The code is translated from Paul Graham's ANSI Common Lisp book.)
When I run it, I get the following error:
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
What am I doing wrong here?