aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-081/tyler-wardhaugh/clojure/src/tw/weekly/c81/t2.clj8
1 files changed, 4 insertions, 4 deletions
diff --git a/challenge-081/tyler-wardhaugh/clojure/src/tw/weekly/c81/t2.clj b/challenge-081/tyler-wardhaugh/clojure/src/tw/weekly/c81/t2.clj
index 543a1f54b6..c126e053b3 100644
--- a/challenge-081/tyler-wardhaugh/clojure/src/tw/weekly/c81/t2.clj
+++ b/challenge-081/tyler-wardhaugh/clojure/src/tw/weekly/c81/t2.clj
@@ -18,10 +18,10 @@
[source]
(let [cleaner (fn [s] (str/replace s #"(?:[.\"\(\),]|'s|--|\n)" " "))
splitter (fn [s] (str/split s #" "))
- xf (comp (mapcat (comp splitter cleaner))
- (remove #{""})
- (x/by-key identity (x/into []))
- (x/by-key (comp count second) first (x/into (sorted-set))))]
+ xf (comp (mapcat (comp splitter cleaner)) ; wordify
+ (remove #{""}) ; discard empty strings
+ (x/by-key identity (constantly 1) (x/reduce +)) ; hash (word => count)
+ (x/by-key second first (x/into (sorted-set))))] ; invert hash, combine words
(into (sorted-map) xf source)))
(defn -main