Map is a function which will take an array and a function and return an array after applying that function to each element in that list
defmodule MyList do
def map([], _func) do
[]
end
def map([head | tail], func) do
[func.(head) | map(tail, func)]
end
end
Copy paste in iex
and execute:
MyList.map [1,2,3], fn a -> a * 5 end
Shorthand syntax is MyList.map [1,2,3], &(&1 * 5)