Another approach, preserving the order of list-a, would be (remove (comp (into #{} (map key-fn list-b)) key-fn) list-a)
On Monday, March 11, 2013 10:01:09 PM UTC+1, Marko Topolnik wrote: > > > I have two lists which contain java objects of the same class. I am trying >> to find out if there is a clojure function which i can use to compare those >> lists based on a key and return the objects from list A that do not exist >> in list B. >> > > Lists as in Clojure lists, or as in java.util.Lists? > > Anyway, since you apparently need your own equality function (can't rely > on Object#equals), you'll have to build more structures. Make a function > that extract the key from the entire object, say *key-fn*, and then do > > (apply dissoc (into {} (map #(-> [(key-fn %) %] list-a))) (map key-fn > list-b)) > > -- -- 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.