Hello all,
I'm very new to clojure, so to familiarize myself I decided to try to
implement the quicksort. My code looks like this:
(defn qsort
([] nil)
([list]
(let [piv (peek list)
f-half (filter (fn [n] (<= n piv))
(pop list))
s-half (filter (fn [n] (> n piv)) (pop list))]
(concat (qsort f-half) (cons piv (qsort
s-half))))))
This looks logical to me, but when I try to run it, I get the
following exception:
user=> (qsort [4 1 3])
java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to
clojure.lang.IPersistentStack (NO_SOURCE_FILE:0)
I have tried wrapping a doall around the filter functions, and I get
the same error.
Thanks in advance!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en