September 2013
Intermediate to advanced
548 pages
12h 25m
English
Often we want to refer to a function that is defined in the current module or in some external module. You can use the following notation for this:
fun LocalFunc/ArityThis is used to refer to the local
function called LocalFunc with Arity
arguments in the current module.
fun Mod:RemoteFunc/ArityThis is used to refer to an external function
called RemoteFunc with Arity
arguments in the module Mod.
Here’s an example of a function reference in the current module:
| | -module(x1). |
| | -export([square/1, ...]). |
| | |
| | square(X) -> X * X. |
| | ... |
| | double(L) -> lists:map(fun square/1, L). |
If we wanted to call a function in a remote module, we could refer to the function as in the following example:
| | -module(x2). |
| | ... |
| | double(L) -> lists:map( ... |
Read now
Unlock full access