On Jun 14, 5:04 am, Max Suica <[email protected]> wrote:
> (defn interesting? [pixels in-range? count]
> (let [p-count (reduce-bail (fn [c p] (if (in-range? p) (inc c) c))
> (partial > count) 0 pixels)]
> [( = count yummy-pix-count) p-count]))
Shoot: s/[( = count yummy-pix-count) p-count]))/[( = count p-count) p-
count]))
And wow, writing literate programs is not facilitated by this forum!
Here's the whole listing in copy/paste friendly form:
(defn reduce-bail [f pred? val col]
(let [s (seq col)]
(if s
(if (pred? val)
(recur f pred? (f val (first s)) (next s))
val)
val)))
(defn interesting? [pixels in-range? count]
(let [p-count (reduce-bail (fn [c p] (if (in-range? p) (inc c) c))
(partial > count) 0 pixels)]
[( = count p-count) p-count]))
(interesting? (let [r (take 1000 (repeatedly #(rand-int 10)))]
(println (count (filter #(= % 5) r ))) r) #(= % 5) 93)
(interesting? (repeatedly rand) #(> % 0.99) 1000)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---