Simple exercise with keys in a map

I’m doing an exercise at and the function and result is listed below.

I am expected to code the function below to get the result.


 # %{?A => 4, ?T => 1, ?C => 0, ?G => 0}

I have no idea how I can get the keys as variables with ? marks in front of them.
I discovered the Enum.fequencies and functions, and that is as far as I’ve been able to get, and those methods give the codepoint as keys and not the ? representation.

As a side note, is this something elixir programmers would actually do or is this just a code exercise that is slightly off the rails ?

The notation ?A is a symbolic representation of the number value for the character A. It is therefore a constant, not a variable. So:

iex> ?A == 65

Map keys can be any Elixir/erlang term. You will find this notation commonly used.