How to write this in Clojure? Example from PAIP

2010-09-29 Thread nickikt
Hallo all, I'm started working on PAIP and doing the examples in Clojure. I understand what this function does (i think) now but I'm not sure how to write it in Clojure since I have no CL background. (defun find-all (item sequence rest keyword-args key (test #'eql) test-not

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread David Sletten
On Sep 29, 2010, at 3:55 AM, nickikt wrote: (defun find-all (item sequence rest keyword-args key (test #'eql) test-not allow-other-keys) Find all those elements of sequence that match item, according to the keywords. Doesn't alter sequence. (if test-not (apply

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread Meikel Brandmeyer
Hi, a slight enhancement for 1.2: Clojure now supports keyword arguments directly. (defn find-all [item coll {:keys [test test-not] :or {test =}}] (if test-not (remove #(test-not item %) coll) (filter #(test item %) coll))) Sincerely Meikel -- You received this message because

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread nickikt
Thx, for your answers. Helps alot. I think the clojure version is cleaner. The meaning of all those ... words are confusing in CL. -- 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

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread David Sletten
On Sep 29, 2010, at 11:01 AM, Meikel Brandmeyer wrote: Hi, a slight enhancement for 1.2: Clojure now supports keyword arguments directly. (defn find-all [item coll {:keys [test test-not] :or {test =}}] (if test-not (remove #(test-not item %) coll) (filter #(test item %)

Re: How to write this in Clojure? Example from PAIP

2010-09-29 Thread Meikel Brandmeyer
Hi, Am 29.09.2010 um 21:37 schrieb David Sletten: I was trying to remember how to do the new keywords, but I couldn't find an example. You have the default value for :test in there too. It's basically normal map destructuring in the varags position, ie. after the in the argument list.