Call a function: Difference between revisions
→{{header|langur}}
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) |
||
Line 3,668:
=={{header|langur}}==
There are
=== parentheses ===
You can always call a function using parentheses.
<syntaxhighlight lang="langur"
x()
</syntaxhighlight>
<syntaxhighlight lang="langur"
write(somestring)
</syntaxhighlight>
=== unbounded argument lists ===
In statement context, you can call a function with an unbounded list of arguments.
<syntaxhighlight lang="langur"
writeln a, b, c
</syntaxhighlight>
=== forwarding operator ===
When passing a single argument, you can use the forwarding operator.
<syntaxhighlight lang="langur">
a -> len
# passes a to the len() function
</syntaxhighlight>
=== recursion ===
Use the fn token with double parentheses to call self.
<syntaxhighlight lang="langur">
val fibonacci = fn x:if x < 2 { x } else { fn((x - 1)) + fn((x - 2)) }
</syntaxhighlight>
=={{header|Latitude}}==
|