IllegalArgumentException Error in Clojure -
i error:
illegalargumentexception don't know how create iseq from: clojure.lang.symbol clojure.lang.rt.seqfrom (rt.java:542)
when call function:
(defn my-butlast [lista] (loop [c lista last ()] (if (= (count c) 1) last (recur (concat last (first c)) (pop c))))) the function should return list same elements input list excluding last element, or '()' if it's empty.
and error happens when list has 2 or more elements this:
(my-butlast '(a b))
concat: "concatenation of elements in supplied colls" (taken https://clojuredocs.org/clojure.core/concat). error seems consistent not passing concat correct argument types. try using conj in place of concat, or else wrapping second argument concat in vector.
if choose conj sure understand different behavior between conj-ing onto list verses onto vector: https://clojuredocs.org/clojure.core/conj
Comments
Post a Comment