On Feb 28, 2:54 am, logan <duskli...@gmail.com> wrote: > Let's say I want to write a function that takes as an argument a list > of n numbers, and returns 4 lists, a list of odd numbers that are > multiples of 5, a list of even numbers that are multiples of 5, a list > of odd numbers that are not multiples of 5, and a list of even numbers > that are not multiples of 5. (...)
I don't know if more efficient solutions exist, but you could use clojure.contrib.seq-utils/group-by (which is implemented using reduce). user> (group-by (juxt odd? #(zero? (mod % 5))) (range 20)) {[false false] [2 4 6 8 12 14 16 18], [false true] [0 10], [true false] [1 3 7 9 11 13 17 19], [true true] [5 15]} -- 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