Skip to content

Instantly share code, notes, and snippets.

@tomjack
Created July 27, 2011 03:16
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 tomjack/f16a81797f1eb160d4b5 to your computer and use it in GitHub Desktop.
Save tomjack/f16a81797f1eb160d4b5 to your computer and use it in GitHub Desktop.
user> (->> ["foo" "foo" "bar" "foo" "baz" "bing" "bing" "foo" "bar"]
(reductions (fn [[m i] v]
(let [m* (assoc m v (get m v (count m)))]
[m* (m* v)]))
nil)
next
(map second))
(0 0 1 0 2 3 3 0 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment