Created
June 3, 2016 23:47
-
-
Save ecounysis/59478840c99d317f2e857ebfde935ee0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 summarize | |
"Summarizes a data set. Groups data by result of groupingf applied to each | |
member of coll. Applies summarizingf to each group." | |
[groupingf summarizingf coll] | |
(let [grouped (group-by groupingf coll)] | |
(map #(list (first %) (summarizingf (second %))) grouped))) | |
(defn summarize-count | |
[groupingf coll] | |
(summarize groupingf count coll)) | |
; juxt is the non-str version of catf | |
(defn catf | |
[sep & fs] | |
(fn [x] | |
(clojure.string/join sep ((apply juxt fs) x)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment