Call a function: Difference between revisions
→{{header|langur}}
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3,668:
=={{header|langur}}==
Functions are first-order, and may be passed around, whether user-defined or built-in.
There are several ways to call a function in langur.
Line 3,696 ⟶ 3,698:
=== recursion ===
Use the fn token with double parentheses
<syntaxhighlight lang="langur">
val fibonacci = fn x:if x < 2 { x } else { fn((x - 1)) + fn((x - 2)) }
</syntaxhighlight>
=== argument expansion ===
Use the expansion operator (...) to pass a list as multiple arguments. The following example works if wordsets is a list of lists, and passes each list as a separate argument to the mapX function.
<syntaxhighlight lang="langur">
mapX(amb, wordsets...)
</syntaxhighlight>
|