Can someone explain why, in Elixir, the "capture operator", denoted as an ampersand prefix, is needed? In other languages it isn't :
Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
>>> def double(x):
... return(x + x)
...
>>> double(2)
4
>>> dbl = double
>>> dbl(2)
4
This works the same in Elixir, apparently:
iex(2)> double = fn x -> x + x end
#Function<6.118419387/1 in :erl_eval.expr/5>
iex(3)> double.(2)
4
iex(4)> dbl = double
#Function<6.118419387/1 in :erl_eval.expr/5>
iex(5)> dbl.(2)
4
So why, for example here, do we ever need to use a capture operator if the function can already be passed around without said operator? Doesn't the plain old name of the function already "capture" it?
iex(10)> Enum.map([1, 2, 3], double)
[2, 4, 6]
Basically I don't understand the use case for the & capture operator and what advantages it affords.