Higher-order functions: Difference between revisions

(→‎TI-89 BASIC: new example)
Line 596:
>>> array.sort(function (a, b) { return a < b });
[97, 34, 24, 18, 13, 5, 4, 2]</lang>
 
=={{header|Joy}}==
This example is taken from V.
Define first as multiplying two numbers on the stack.
<lang joy>
DEFINE first == *.
</lang>
There will be a warning about overwriting builtin first.
Define second as interpreting the passed quotation on the stack.
<lang joy>
DEFINE second == i.
</lang>
Pass first enclosed in quotes to second which applies it on the stack.
<lang joy>
2 3 [first] second.
</lang>
The program prints 6.
 
=={{header|Logo}}==
153

edits