On Fri, Aug 14, 2009 at 3:43 PM, Fogus<mefo...@gmail.com> wrote:
>
> Wanna play golf?

Yes I do!

(defn filter-collecting [p c & l]
  (remove nil? (apply map #(when % (apply c %&)) (apply map p l) l)))

But that gives incorrect results if c ever returns nil, so
I guess it should be:

(defn filter-collecting [p c & l]
  (let [x `x#]
    (remove #(= % x)
                (apply map #(if % (apply c %&) x)
                                   (apply map p l)
                                           l))))

But that's getting pretty ugly, so maybe this is better:

(defn filter-collecting [p c & l]
  (map #(apply c %)
       (filter #(apply p %)
                   (apply map vector l))))

Nothing terribly inventive there.  I'll have to get my
satisfaction from being first.  I'm sure the best are yet to
come...

--Chouser

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to