Higher-order functions: Difference between revisions

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