Created
October 26, 2015 04:20
-
-
Save terakilobyte/6dad6eee77ab59fbd787 to your computer and use it in GitHub Desktop.
** (CondClauseError) no cond clause evaluated to a true value
This file contains hidden or 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
Enum.reduce(sentence, %{}, | |
fn(word, acc) -> | |
cond do | |
Map.has_key?(acc, word) -> | |
acc = Map.update(acc, word, 1, &(&1 + 1)) | |
true | |
acc = Map.put(acc, word, 1) | |
end | |
end | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment