On Jun 12, 4:56 pm, CuppoJava <patrickli_2...@hotmail.com> wrote: > I would approach it like this, and make full use of Clojure's lazy > sequences: > > (count (take-while belowCount (filter identity (map isInteresting > pixels))))
This particular piece of code doesn't look like it would work, unless I've misunderstood what Vlad is asking. I think you'd want something more like: (defn interesting? [pixels c] (>= c (count (take c (filter in-interval? pixels))))) Where c is the number past which an image is considered "interesting". However, if c is very large, then (take c ...) is going to result in a large sequence. We'd probably want to define a function: (defn count-more-than? [n xs] (or (zero? n) (if (seq xs) (recur (dec n) (rest xs))))) (defn interesting? [pixels c] (count-more-than? c (filter in-interval? pixels))) - James --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---