On Sat, Aug 7, 2010 at 6:12 PM, David Cabana <drcab...@gmail.com> wrote: > Speed is no big deal for me; the sequences I'm handling are short, say > about length100. BTW, one of these is considerably faster than the > other for longish sequences. Can you guess which? > if you don't mind about performance, this seems to be natural to me
user=> (reverse (map reverse (reduce (fn [a e] (if (even? e) (cons [e] a) (cons (cons e (first a)) (rest a)))) (list) [1 2 3 7 5 4 1]))) ((1) (2 3 7 5) (4 1)) Othewise, I would look for a foldr solution. Talking about foldr, is it in clojure.core ? -- 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