Hi, On Oct 14, 4:42 pm, Mark Tomko <mjt0...@gmail.com> wrote:
> (defn count-matching-elements [coll1 coll2] > (reduce + > (for [e1 coll1 e2 coll2] > (if (= e1 e2) 1 0)))) Please note, that this probably is not what you meant: (for [x [1 2] y [4 5]] (vector x y)) => ([1 4] [1 5] [2 4] [2 5]) You can remove items from the list with :when. (for [x [1 2] y [4 5] :when (odd? (+ x y))] (vector x y)) => ([1 4] [2 5]) Your original question can be done with for also: (defn matching-elements-x [s1 s2] (for [[e1 e2] (partition 2 (interleave s1 s2)) :when (= e1 e2)] e1)) 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 -~----------~----~----~----~------~----~------~--~---