Tutorial by Examples

Map

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 ...
Reduce is a function which will take an array, function and accumulator and use accumulator as seed to start the iteration with the first element to give next accumulator and the iteration continues for all the elements in the array (refer below example) defmodule MyList do def reduce([], _func,...

Page 1 of 1