Created
February 17, 2016 04:28
-
-
Save jmsevold/0ec346af33d7a5898779 to your computer and use it in GitHub Desktop.
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
defmodule Words do | |
@doc """ | |
Count the number of words in the sentence. | |
Words are compared case-insensitively. | |
""" | |
@spec count(String.t) :: map() | |
def count(sentence) do | |
end | |
end | |
map = %{} | |
split_words = String.split(words) | |
Enum.each(split_words, &(Map.put(map,String.to_atom(&1),1)) | |
# reduce a list of strings to a map whose keys are the strings, and values are a number representing the occurence of that string within the list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment