Trying to pass a custom function to the following function but I have no luck.
defmodule M do
def custom_fn([head|tail],fnce) do
fnce.(head)
custom_fn(tail,fnce)
end
def custom_fn([]), do: nil
end
Trying to call it like this:
M.custom_fn([1,2,3], (fn(x) -> x * 10 end))
Getting this
** (FunctionClauseError) no function clause matching in M.custom_fn/2
The following arguments were given to M.custom_fn/2:
# 1
[]
# 2
#Function<6.99386804/1 in :erl_eval.expr/5>
test.ex:11: M.custom_fn/2
Also, what does the following message say? M.custom_fn/2
To be more specific, I don't understand /2.