Created
March 27, 2012 15:37
-
-
Save mwmitchell/2217129 to your computer and use it in GitHub Desktop.
list filtering
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
(let [candidates [{:udicode 1} {:udicode 2} {:udicode 3} {:udicode 4} {:udicode 1} {:udicode 9} {:udicode 20}] | |
result (atom #{}) | |
filters [#(not (@result %)) | |
#(< (:udicode %) 10)] | |
include? (fn [h] | |
(if (every? #(% h) filters) | |
(swap! result conj h)))] | |
(take 7 (filter include? candidates))) | |
;; using juxt and reduce for applying the filters: | |
(reduce #(and %1 %2) ((apply juxt [nil? keyword? (constantly true)]) nil)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment