Debug console
Welcome to Elixir!
[nofile:10: (file)]
sentence #=> "Welcome to Elixir!\n"
|> String.downcase() #=> "welcome to elixir!\n"
|> String.replace(~r/\W+/, "") #=> "welcometoelixir"
|> String.graphemes() #=> ["w", "e", "l", "c", "o", "m", "e", "t", "o", "e", "l", "i", "x", "i", "r"]
|> Enum.frequencies() #=> %{
"c" => 1,
"e" => 3,
"i" => 2,
"l" => 2,
"m" => 1,
"o" => 2,
"r" => 1,
"t" => 1,
"w" => 1,
"x" => 1
}
Result:
%{"c" => 1, "e" => 3, "i" => 2, "l" => 2, "m" => 1, "o" => 2, "r" => 1, "t" => 1, "w" => 1, "x" => 1}
Note: The code is run in a sandbox powered by Dune.
Its behavior might slightly differ from Elixir and only a restricted subset is supported.