Chouser a écrit : > How about this one? Same results as in my previous post. Still as > lazy as possible. Plus it's so cute! > > (defn reduction > "Returns a lazy seq of the intermediate values of the reduction (as > per reduce) of coll by f, starting with init." > ([f coll] > (if (seq coll) > (lazy-cons (first coll) (map f (reduction f coll) (rest coll))) > (cons (f) nil))) > ([f init coll] > (lazy-cons init (map f (reduction f init coll) coll)))) > But I don't think it's still O(n). I searched for a way to define recursively such lists but the only way I found involves using mutation. Now with an atom it must be cleaner.
Christophe --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---