I'm doing some file streaming with a lazy list and I ran into a problem where I had to process a whole chunk at a time, so I wrote this function. Just posting to see if I'm reinventing something or if it might be a good addition to contrib.
(defn in-smaller-lists [the-list smaller-list-size] (lazy-seq (let [[fnbr the-rest] (split-at smaller-list-size the-list)] (if (first the-rest) (cons fnbr (in-smaller-lists the-rest smaller-list-size)) (list fnbr)) ))) Example: user=> (in-smaller-lists (range 11) 3) ((0 1 2) (3 4 5) (6 7 8) (9 10)) I do database work and this is very useful for processing a csv n rows at a time. Travis --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---