Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; 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