I'm pretty new to elixir and functional programming in general and I am having a map of the form:
key => [int, int]
for example:
14 => [1,0]
Using the snippet below, I have managed to increase the value of 1 in [1,0] by 1 but I don't manage to do the same for the second value, aka '0'.
This is my working sample code for the head of the list
iex(2)> a = Map.update!(a, 'b', fn([a|b]) -> [a+1] ++ b end)
This is my code and the error I get for the second element of the list, please note that my list is only consisting of 2 elements and this is not going to change
iex(3)> a = Map.update!(a, 'b', fn([a|b]) -> a ++ [b+1] end)
** (ArithmeticError) bad argument in arithmetic expression
:erlang.+([0], 1)
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:228: :erl_eval.expr/5
(stdlib) erl_eval.erl:470: :erl_eval.expr/5
(elixir) lib/map.ex:727: Map.update!/3