Created
June 19, 2013 20:07
-
-
Save tonini/5817579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From the Elixir language *master* documentation. | |
Function retrieval | |
The function macro can also be used to retrieve local, imported and remote functions. | |
square = fn(x) -> x * x end | |
Enum.map [1,2,3], function(square/1) | |
** (UndefinedFunctionError) undefined function: :erl_eval.square/1 | |
:erl_eval.square/1 | |
:erl_eval.expr/3 | |
defmodule MyMath do | |
def square(x) do | |
x * x | |
end | |
end | |
Enum.map [1,2,3], function(MyMath.square/1) | |
# [1, 4, 9] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment