I am learning Elixir and according to the linked book (page 64), the following function:
defmodule MyList do
def square([]), do: []
def square([ head | tail ]), do: [ head*head, square(tail) ]
end
should behave as follows:
MyList.square [4, 5, 6]
[16, 25, 36]
But when I plug it into my Elixir 1.2.0 installation on Ubuntu I get:
MyList.square [4, 5, 6]
[16, [25, [36, []]]]
What's happening here? Am I wrong or is the book wrong?
How do I get to the simple [16, 25, 36] ?