I am trying to get list numbers 17 digits long, then splitting it with Integer.digits
, and getting the sum of those numbers. Unfortunately I've been getting unexpected behavior (my results contain a string of letters) and not sure if this is a bug or just personal mistakes.
Below is iex
console of the error, results give 'Q $'
:
iex(4)> numbers = [
...(4)> [1, 4, 8, 1, 3, 6, 9, 4, 2, 5, 5, 6, 3, 1, 8, 8, 7],
...(4)> [1,5, 9, 4, 1, 3, 2, 7],
...(4)> [1, 5, 4, 6, 5, 7, 8]
...(4)> ]
iex(5)> Enum.map(numbers, fn x -> Enum.sum(x) end)
'Q $'
But when I remove a number from the last list it works correctly again, and gives the results expected
iex(1)> numbers = [
...(1)> [1, 4, 8, 1, 3, 6, 9, 4, 2, 5, 5, 6, 3, 1, 8, 8, 7],
...(1)> [1,5, 9, 4, 1, 3, 2, 7],
...(1)> [1, 5, 4, 6, 5, 7]
...(1)> ]
iex(2)> Enum.map(numbers, fn x -> Enum.sum(x) end)
[81, 32, 28]
Is this expected behavior? Or is there some way around this, because each of my lists will need to sum 17 individual digits.