Inconsistent Enum.map output

Hi, I’m a little dumbfounded with the following iex session that I ran:

iex(7)> Enum.map([4,5,6], &(2 * &1))  
'\b\n\f'
iex(8)> Enum.map([1,5,6], &(2 * &1))
[2, 10, 12]
iex(9)> Enum.map([1,2,3], &(2 * &1)) 
[2, 4, 6]
iex(10)> Enum.map([7,8,9], &(2 * &1))
[14, 16, 18]
iex(11)> Enum.map([4,5,6,7], &(2 * &1))
[8, 10, 12, 14]
iex(12)> 

What is special about the list [4,5,6] (see first two lines of code and its output) that the output is entirely different in meaning from the rest? What am I failing to understand here?
Any ideas?
Thank you.

[8, 10, 12] == '\b\n\f'

So the value is correct. What’s surprising (to you) is how iex (actually IO.inspect/2 behind the scene) shows the list in that format.

That is because iex treat it as charlist (note it’s with single quote, not double quote)

IO.inspect([8, 10, 12])

IO.inspect([8, 10, 12], charlists: :as_lists)
6 Likes

Thank you :pray: