On Sun, Jun 14, 2009 at 4:00 AM, Sudish Joseph<[email protected]> wrote:
>
> On Jun 13, 4:17 pm, Laurent PETIT <[email protected]> wrote:
>> So it really seems to me that the missing abstraction, here, is being
>> able to do a reduce over the list of pixels, and being able, from the
>> reduction function, to quit the reduction early.
>
> A lazy right fold[1] allows short-circuiting, so here's one attempt:

Here's another way to do a sort of lazy reduce:

(use '[clojure.contrib.seq-utils :only [reductions]])

(some #(> % 10)
      (reductions (fn [counter pixel] (if (< pixel 10) (inc counter) counter))
                      0 (iterate dec 15)))

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to