Hi, On Oct 20, 3:08 am, Dmitry Kakurin <dmitry.kaku...@gmail.com> wrote:
> (defn multi-filter [filters coll] > (reduce > (fn [res e] > (map (fn [f r] (if (f e) (conj r e) r)) > filters > res)) > (repeat (count filters) []) > coll > ) > ) I think this basically equivalent to the juxt solution. Besides your are using sequence, where juxt uses vectors directly. Maybe that is a bit faster? Dunno. Stylistic: you should not put the closing parens on dedicated lines. They are normally collected on the last line. While this is only a style issue, you should get used to it, since 99.9% of all code at in the wild will use that style... > Interestingly enough replacing map with eager-map in multi-filter > definition gives very insignificant boost in perf (less than 10%), so > I've decided to leave it as is. > May be there are improvements possible to my emap definition? > > (defn emap [f c1 c2] > (loop [s1 (seq c1) s2 (seq c2) res [] ] > (if (and s1 s2) > (recur (seq (rest s1)) (seq (rest s2)) (conj res (f (first s1) > (first s2)))) > res))) Use next instead of the seq-rest combination. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---