On Mon, Jan 26, 2009 at 6:24 AM, e <evier...@gmail.com> wrote: > ok, I'll check that stuff out. Thanks. > > It occurs to me this is being compared to something in ruby called > partition. I like that name. "partition-by" ... but maybe it was opted to > use the simpler name, which I can appreciate.
There is already a function called "partition": user=> (doc partition) ------------------------- clojure.core/partition ([n coll] [n step coll]) Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. nil user=> (range 21) (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) user=> (partition 7 (range 21)) ((0 1 2 3 4 5 6) (7 8 9 10 11 12 13) (14 15 16 17 18 19 20)) user=> (partition 2 (range 21)) ((0 1) (2 3) (4 5) (6 7) (8 9) (10 11) (12 13) (14 15) (16 17) (18 19)) user=> (partition 2 3 (range 21)) ((0 1) (3 4) (6 7) (9 10) (12 13) (15 16) (18 19)) Note: If the collection cannot be divided evenly then some elements at the end are discarded. -- Michael Wood <esiot...@gmail.com> --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---