I am trying to dissect and understand how the acc/0
and reducer/0
work within the Enumerable Protocol.
def map(enumerable, fun) do
reducer = fn x, acc -> {:cont, [fun.(x) | acc]} end
Enumerable.reduce(enumerable, {:cont, []}, reducer) |> elem(1) |> :lists.reverse()
end
Could someone explain this starting from the values of x, acc in each enumeration
New contributor
zdean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1