How to Convert String to Key Value Map of Items and Count Number

From ElixirBlocks
Jump to: navigation, search
words = "The world hello world to the world"

list = String.split(words," ")
Enum.map(list, fn(item)->  item end)|>
Enum.frequencies()|>
IO.inspect              #%{"The" => 1, "hello" => 1, "the" => 1, "to" => 1, "world" => 3}