Re: Reduce a function over more than one sequence (like map)

2010-06-12 Thread Jürgen Hötzel
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

Re: Reduce a function over more than one sequence (like map)

2010-06-12 Thread Nathan Sorenson
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

Reduce a function over more than one sequence (like map)

2010-06-11 Thread Nathan Sorenson
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

Re: Reduce a function over more than one sequence (like map)

2010-06-11 Thread Steve Purcell
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

Re: Reduce a function over more than one sequence (like map)

2010-06-11 Thread Sean Devlin
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