Use &Module.function/arity
to pass it, and .(…)
to call it.
For example:
def my_hof(f)
f.([1, 2, 3], &(&1 * 2))
end
my_hof(&Enum.map/2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With