Skip to content

Instantly share code, notes, and snippets.

@tomjack
Created January 28, 2010 00:16
Show Gist options
  • Save tomjack/d959ec8067aab3be40b5 to your computer and use it in GitHub Desktop.
Save tomjack/d959ec8067aab3be40b5 to your computer and use it in GitHub Desktop.
(defn count-bigrams
"Takes a seq of bigram pairs into a map of (pair -> count)"
[bigrams]
(reduce (fn [accum next-bigram]
(assoc accum next-bigram (inc (get accum next-bigram 0))))
{}
bigrams))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment