Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created May 9, 2017 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/5a915a29f44e47f32d24735398ee8224 to your computer and use it in GitHub Desktop.
Save deque-blog/5a915a29f44e47f32d24735398ee8224 to your computer and use it in GitHub Desktop.
(defn freq-map
"Optimized version of the frequency map"
[coll]
(let [freqs (java.util.HashMap.)]
(doseq [val coll]
(.put freqs val (inc (get freqs val 0))))
freqs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment