Reputation: 15
So I've got this list returned from calling lines:
(def lines (into () (clojure.string/split-lines (slurp "input.txt"))))
And I've got these two functions:
(defn tokenize-line [x] (clojure.string/split x #" " ))
(defn tokenize-list [lst] (for [x lst] (tokenize-line [x])))
When I pass (lines)
as a parameter to tokenize-list
, I get this error:
ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
I can't figure out where this error comes from, any help would be amazing!
Upvotes: 0
Views: 79
Reputation: 20194
In clojure (lines)
means "call the function lines with no arguments". As we see from your definition, lines
is not a function, it's a list.
Also, in (tokenize-line [x])
you pass a vector, containing the String x, to a function that expects a String.
Further, when you run (into () ...)
this takes something that was already a sequence, and turns it into a reversed sequence (because of the behavior of ()
when you add elements, they end up in reversed order).
Upvotes: 2