Hi, folks. I'm wondering if Clojure library has 'reduce' function version which is like (reduce f coll) - i.e. it applies function to coll elements without the initial value but at the same time allows to use external accumulator which is passed to f as well. Better look at the code:
(defn reduce-with-acc "Applies f to first two coll elements and acc producing new acc value for subsequent f calls. Returns acc. On singleton or empty collection returns acc immediately." [f acc coll] (loop [a (first coll) acc acc s (next coll)] (if (seq s) (let [b (first s)] (recur b (f a b acc) (next s))) acc))) Regards, Alexander. -- 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