On Jun 13, 9:57 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > > The filter and map functions produce lazy seqs, so the sequence is > > only walked once. > > Well, isn't walking 3 different sequences 1 time almost equivalent (in > terms of computer work) to walking 3 times one sequence ?
Well, I guess there's the overhead of wrapping it in multiple seqs, but the logic calculations will be the same regardless of which method is used. > And nevertheless, if I insist, it's not really because there *could* > be a performance problem (though I guess there will, but only > benchmark would tell), but rather because the essence of the problem > seems to be needing a simple reduction with early break capability, > and no more :-) Well, I kinda disagree here. It seems to me that this: (defn interesting? [pixels c] (> c (count (take c (filter in-interval? pixels)))) Is more straightforward than: (defn interesting? [pixels c] (reduce (fn [counter pixel] (if (in-interval? pixel) (inc counter) counter)) 0 pixels (partial < c))) - 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 -~----------~----~----~----~------~----~------~--~---