Thanks guys for the various solutions. I set out trying to try a recur solution

So I came up with this. the idea is to go through the collection being
passed, and grab one element, then do drop-while until a different
element is encountered. repeat until there is no more left in the collection.

(defn group [x]
(loop [newlist [] currlist x]
  (if (not (empty? x))
    (recur (newlist (cons (first x) newlist))
           (currlist (drop-while #(= (first currlist) %) currlist))
           ))))


It seems logical to me, but when I tried it with
(group [1 1 2 2 3 3 ])

I get
CompilerException java.lang.IllegalArgumentException: Key must be integer

what am I missing?

Thanks

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to