Skip to content

Instantly share code, notes, and snippets.

@ericnormand
Created August 17, 2009 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericnormand/169171 to your computer and use it in GitHub Desktop.
Save ericnormand/169171 to your computer and use it in GitHub Desktop.
;; 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