Skip to content

Instantly share code, notes, and snippets.

@ashafa
Last active December 31, 2015 06:49
Show Gist options
  • Save ashafa/7950036 to your computer and use it in GitHub Desktop.
Save ashafa/7950036 to your computer and use it in GitHub Desktop.
(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