Created
October 25, 2011 17:09
-
-
Save Quantisan/1313522 to your computer and use it in GitHub Desktop.
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
(defn match-count | |
" Given key, k, returns number of occurrences of k in collection, coll. | |
" | |
[k coll] | |
(let [match? (fn [i x] | |
(if (= k x) ;; closure on k | |
(inc i) | |
i))] | |
(reduce match? 0 coll))) | |
(defn calc-counts | |
" Returns a list of counts for the occurrences of each key of keys, ks, | |
within the collection, coll. | |
" | |
[ks coll] | |
(pmap #(match-count % coll) ks)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment