-
-
Save tomjack/d959ec8067aab3be40b5 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 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