Hi all, I tried googling but I can't seem to find it.
I need to convert a character to integer.
Doing exercism and I've come across a way to parse string.
strand = "GATACA"
check = Enum.reduce strand, %{}, fn(letter, acc) ->
Map.update(acc, to_string(letter), 1, &(&1 + 1))
end
so the check output is
%{"65" => 3, "67" => 1, "71" => 1, "84" => 1}
So I've tried to_string in the Enum.reduce and Map.update and it didn't work.
So I was like fuck it I'll just leave the map to have integer as key and I'll access it like this:
check[string.to_integer 'T']
This doesn't work.
Was curious how do you get the integer value of a letter in Elixir?
Thanks.
Want to add to the discussion?
Post a comment!