Is the following an improvement on clojure.contrib.seq-utils/ 
reductions, or a step backwards?

(defn my-reductions
   ([f coll]
      (if (seq coll)
        (cons (first coll) (my-reductions f (first coll) (rest coll)))
        (cons (f) nil)))
   ([f acc coll]
      (if (seq coll)
        (let [nextval (f acc (first coll))]
          (lazy-seq (cons nextval (my-reductions f nextval (rest  
coll))))))))

On the plus side, it appears to be faster (as collections grow large),  
and it doesn't "cheat" by introducing an atom. On the minus side it  
isn't as pretty as the one in contrib.

Stu

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