Thanks Marko. I do have couple more q's for you just to ensure I got everything right:
(comp keyset-b key-fn) > This results in a function that first applies *key-fn*, then *keyset-b*. > So it's like #(keyset-b (key-fn %)). Let's call this function *predicate*. 1. What exactly happens when an item is passed to #(keyset-b (key-fn %)) ? Does keyset-b looks up itself (because collections are functions) for the item which contains *:id X *and returns true/false? 2. Isn't it more idiomatic to write #((key-fn %) keyset-b) ? 3. Does remove loops list-a internally and applies the predicate to each item? (if the answer is no my head will definitely explode) Thanks again for your patience :) Ryan On Thursday, March 21, 2013 6:09:42 PM UTC+2, Marko Topolnik wrote: > > Personal preference. It causes less mental load because it more obviously > spells out what you are doing. > > On Thursday, March 21, 2013 4:58:08 PM UTC+1, Ryan wrote: >> >> Thanks a lot Marko. Much better now :) >> >> I also wanted to ask you why did you mention in a previous post that you >> prefer using *remove *than *filter + complement*. Is there a reason for >> this or just a personal preference? >> >> Ryan >> >> On Thursday, March 21, 2013 5:37:33 PM UTC+2, Marko Topolnik wrote: >>> >>> First we build a set of all the keys in *list-b*: >>> >>> (into #{} (map key-fn list-b)) >>> >>> Let's call that set *keyset-b. *Then we use *keyset-b* as a function >>> which returns truthy (non-nil) for any key that is contained in it, and >>> compose it with our *key-fn*: >>> >>> (comp keyset-b key-fn) >>> >>> This results in a function that first applies *key-fn*, then *keyset-b*. >>> So it's like #(keyset-b (key-fn %)). Let's call this function *predicate >>> *. >>> >>> Finally, we use *predicate* to *remove* any member of *list-a* for >>> which it is truthy: >>> >>> (remove predicate list-a) >>> >>> -marko >>> >>> On Thursday, March 21, 2013 4:14:46 PM UTC+1, Ryan wrote: >>> >>>> Marko, >>>> >>>> Can you please do me a favor and break down the function you suggested >>>> me? I understand partially how it works but I am having trouble to fully >>>> get it. >>>> >>>> (remove (comp (into #{} (map key-fn list-b)) key-fn) list-a) >>>>> >>>> -- -- 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.