> but apply works very well for this use case: (apply < (range 10))
> and it stops as soon as it can:
Alright, I fold... thanks for clearing things up Christophe!
On Tue, Feb 3, 2009 at 3:13 PM, Christophe Grand wrote:
>
> Stu Hood a écrit :
> > I still think the
> > (< (range 10))
> > ... use c
Stu Hood a écrit :
> I still think the
> (< (range 10))
> ... use case is really worthwhile though, and I don't see a way to
> accomplish it with reduce.
reduce is not a good fit since you would want to short circuit the
computation at the first false.
but apply works very well for this use cas
> This is a common misconception: passing a seq to apply doesn't force its
> evaluation.
Ahh, is this because the [& more] portion is itself a lazy sequence? That's
very cool =)
Hmm, the (reduce + ...) approach works just fine, but if it is already
implemented as reduce, it seems like it would be
Hello,
stuhood a écrit :
> Functions like (+), (*), (-), (and probably more) should support
> sequences as parameters.
>
> The current way to accomplish this (without implementing your own sum
> using reduce) seems to be:
>
>> (apply + (map #(. Math pow 2 %) (range 10)))
>>
> ... which ha
Functions like (+), (*), (-), (and probably more) should support
sequences as parameters.
The current way to accomplish this (without implementing your own sum
using reduce) seems to be:
> (apply + (map #(. Math pow 2 %) (range 10)))
... which has to generate the sequence first.
Instead, you sho