On Dec 24, 2008, at 1:57 PM, MattyDub wrote:
(Originally, I didn't know about the 2-argument version of range, so I was using map and an anonymous inline function to add 1 to each result from range, like: (map #(sum-up-to (inc %)) (range 12)) Then I thought "This can't be right, there has to be a way to do this already", and looked at the docs for range. It's nice when you find something you want already exists - thanks, Rich!) Fun times - thanks, clojure! -Matt PS I'm sure there are versions of this that are shorter (1 line?) or perform better (e.g., by caching previous sums or something) - but I'll leave those as an exercise for somebody else. ;)
Nice, Matt! With the "reductions" function recently discussed this becomes: user=> (reduce + (reductions + (range 1 13))) 364 user=> Hmmm, enough gifts for every other day of the year!I don't see "reductions" on the todo list or on the issues list. Is it still being considered for Clojure?
--Steve
smime.p7s
Description: S/MIME cryptographic signature