Last active
December 31, 2015 06:49
-
-
Save ashafa/7950036 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 format-history-lines | |
[history-lines] | |
((comp | |
format-history-map | |
(partial take 10) | |
sort-by-weight | |
counts | |
(partial map history-line->command)) | |
history-lines)) | |
;; ... could be ... | |
(defn format-history-lines | |
[history-lines] | |
(->> (format-history-map) | |
(take 10) | |
(sort-by-weight) | |
(frequencies) ;; (= frequencies counts) You can get rid of the counts fn above | |
(map history-line->command history-lines))) | |
;; Correct order ... | |
(defn format-history-lines | |
[history-lines] | |
(->> (map history-line->command history-lines) | |
(frequencies) | |
(sort-by-weight) | |
(take 10) | |
(format-history-map))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment