2010/6/11 Nathan Sorenson n...@sfu.ca:
Is there a way to fold over multiple sequences, in the same way that
'map' can apply a multi-parameter function over several seqs? In other
words, is there a function like this:
There is no need for a special purpose reduce* function.
Using destructing
Thanks for the replies. Indeed, I have been approaching the issue with
destructuring, as suggested. It still seems to me that reduce* is
consistent with the behaviour of map, in that it is polyvariadic and
doesn't require packing arguments into and out of a single sequence.
However, its good to
Is there a way to fold over multiple sequences, in the same way that
'map' can apply a multi-parameter function over several seqs? In other
words, is there a function like this:
(defn reduce*
[f val colls]
(reduce (fn [acc args] (apply f acc args))
val
On 11 Jun 2010, at 08:59, Nathan Sorenson wrote:
Is there a way to fold over multiple sequences, in the same way that
'map' can apply a multi-parameter function over several seqs? In other
words, is there a function like this:
(defn reduce*
[f val colls]
(reduce (fn [acc
To me this application screams destructuring. Assume you want to
(reduce + ...) a collection of sequences. I'd lead off with a simple
vector mapping operation, and the reduce over the following sequence
like so:
user=(reduce
(fn [[acc-x acc-y] [x y]]
[(+ acc-x x) (+ acc-y y)])
(map