Created
August 17, 2009 15:18
-
-
Save ericnormand/169171 to your computer and use it in GitHub Desktop.
a response to http://blog.fogus.me/2009/08/14/clojure-golf-episode-1/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; this one looks much cleaner, but it holds onto the heads of the lists | |
(defn filter-collecting [predicate collector & lists] | |
(let [tuples (apply map vector lists) | |
filtered (filter #(apply predicate %) tuples)] | |
(map #(apply collector %) filtered))) | |
;; less garbage, but uglier | |
(defn filter-collecting [predicate collector & lists] | |
(map #(apply collector %) (filter #(apply predicate %) (apply map vector lists)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment