Higher-order functions: Difference between revisions

m
Line 1,800:
This example is taken from V.
Define first as multiplying two numbers on the stack.
<langsyntaxhighlight joylang=Joy>DEFINE first == *.</langsyntaxhighlight>
There will be a warning about overwriting builtin first.
Define second as interpreting the passed quotation on the stack.
<langsyntaxhighlight joylang=Joy>DEFINE second == i.</langsyntaxhighlight>
Pass first enclosed in quotes to second which applies it on the stack.
<syntaxhighlight lang joy=Joy>2 3 [first] second.</langsyntaxhighlight>
The program prints 6.
 
153

edits