Hi!

I've noticed that there is group-by in clojure 1.2. However it uses
reduce and conj.
Doesn't it consume all sequence at once?

Here I have lazy version I have written once:

(defn group-by
        [input]
          (lazy-seq
            (when-let [s (seq input)]
              (let [k (ffirst s) [vs r] (split-with #(-> % first (= k)) s)]
                  (cons [k  vs] (group-by r))))))



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