Total Elixir noob here. Here's my question:
When using the Enum.all?/2 function, we pass a function as the second argument:
iex(19)> is_int = &(is_integer(&1))
iex(20)> Enum.all?(list, is_int)
true
Why is it, then, that I can't pass is_integer directly?
iex(21)> Enum.all?(list, is_integer)
** (CompileError) iex:21: undefined function is_integer/0
(stdlib) lists.erl:1354: :lists.mapfoldl/3
(stdlib) lists.erl:1355: :lists.mapfoldl/3
Is is_integer not a function? It looks like that from the error. What is the mapfoldl we see there?
You have to capture this function. Use:
Enum.all?(list, &(is_integer(&1))
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