You have to be careful when using the `&1` notation—when Elixir sees
it, in converts the immediately enclosing expression into a
function. So, the following works:
iex> func = &1 + &2
#Function<erl_eval.12.82930912>
iex> func.(9, 4)
13
However, this doesn't.
iex> func = &1 + &2 + &1
#Function<erl_eval.12.82930912>
iex> func.(9, 4)
** (BadArityError) bad arity error: #Function<erl_eval.6.82930912>
called with [3,4]
That's because `&1 + &2 + &1` is parsed internally as `(&1 + &2) +
&1`. The parenthesized part is self-contained, so Elixir converts it
to
(fn a, b -> a+b end) + &1
Now it continues to parse the line, sees the second `&1` and generates
a second anonymous function, enclosing the whole expression:
fn x -> (fn a, b -> a+b end) + x end
When we call this with two parameters, it raises a bad arity error,
because the outer function only expects one.