On May 28, 2009, at 12:35 AM, Mikio Hokari wrote:
> >>> I wonder if there is a more idiomatic way to compare two lazy >>> sequences... lazily? > > You can just use =. I guess I'm imagining a group-by like Haskell's, which takes an equality comparison function and just returns a list of lists. Which would look like this: (defn span [f coll] (if (empty? coll) ['() '()] (if (f (first coll)) (let [[more & rest] (span f rest)] [(cons (first coll) more) rest]) ['() coll]))) (defn group-by [f [x & xs :as coll]] (if (empty? coll) '() (let [[ys zs] (span #(f x %) xs)] (cons (cons x ys) (lazy-seq (group-by f zs)))))) Now you ought to be able to do this with = on a sorted list as I described in the huge message I sent a bit ago. (remove #(= (length %) 1) (group-by = (sort ...))). Sorting is still the question for me though. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---