Function definition: Difference between revisions

Line 2,156:
Functions defined with explicit parameters may be closures, and those defined with implied parameters are not.
 
Langur functions are first-order. They are pure in terms of setting values, though notand in terms of I/O (unless declared impure).
 
=== explicit parameters ===
Line 2,171:
Operator implied functions are built using an infix operator between curly braces on an f token.
 
{{works with|langur|0.6.6}}
<syntaxhighlight lang="langur">val .multiply = f{x}
.multiply(3, 4)</syntaxhighlight>
Line 2,178 ⟶ 2,177:
These are built with an infix operator and one operand inside the f{...} tokens.
 
{{works with|langur|0.8.11}}
<syntaxhighlight lang="langur">val .times3 = f{x 3}
map .times3, [1, 2, 3]</syntaxhighlight>
 
=== impure functions (I/O) ===
Impure functions must be declared as such.
<syntaxhighlight>val .writeit = impure f(.x) { writeln .x }</syntaxhighlight>
 
Impure functions cannot be passed to pure functions.
 
=={{header|Lasso}}==
885

edits