Thank you all for your replies.

@Marko, well, at first my question was intended to be more generic, but in 
reality I am dealing with two java.util.Lists
I probably didn't described very well what I wanted in the first place. All 
the objects in those lists contain an "id" property which has a unique 
value. I am trying to find out, which objects from the first list, based on 
that "id" property, are not included in list b.

I assume this rules out the use of clojure.data/diff and I will need my own 
function like Marko suggested to make those property comparisons.

Ryan

On Monday, March 11, 2013 11:05:47 PM UTC+2, Marko Topolnik wrote:
>
> 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.


Reply via email to