On Wednesday, January 5, 2011 11:06:34 AM UTC+1, David wrote: > > Consider the two definitions: > > (defn if-let-good [str] > (if-let [rest (seq (drop-while (partial = \a) str))] > (first rest) > "empty")) > > (defn if-let-bad [seq] > (if-let [rest (seq (drop-while (partial = \a) seq))] > (first rest) > "empty")) > > The only difference between them is the name of the arg: "str" in the > good > definition, "seq" in the bad definition. > > (if-let-good "") > => "empty" > > (if-let-bad "") > > aborts with: > > java.lang.String cannot be cast to clojure.lang.IFn > [Thrown class java.lang.ClassCastException] >
Clojure is a Lisp-1: it has a single namespace for functions and variables. If you call your parameter seq, you're shadowing the definition of the seq function (and trying to call the seq parameter as a function, which is the source of the exception you're getting). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en