On Mar 11, 2013, at 17:09 , Ryan <arekand...@gmail.com> wrote: > What if, i had two clojure lists, with hash-maps which have the same keys and > based on a specific key, i wanted to find the items from list-a which do not > exist in list-b. Would i go with the two functions you suggested or is there > something else I could use?
Assuming :id is the key you care about: (filter (comp (complement (set (map :id list-b))) :id) list-a) user=> (defn rand-seq [n] (repeatedly #(rand-int n))) #'user/rand-seq user=> (def list-a (map (partial hash-map :id) (take 5 (rand-seq 10)))) #'user/list-a user=> list-a ({:id 8} {:id 4} {:id 5} {:id 1} {:id 6}) user=> (def list-b (map (partial hash-map :id) (take 5 (rand-seq 10)))) #'user/list-b user=> list-b ({:id 9} {:id 6} {:id 3} {:id 6} {:id 3}) user=> (filter (comp (complement (set (map :id list-b))) :id) list-a) ({:id 8} {:id 4} {:id 5} {:id 1}) -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.