Higher-order functions: Difference between revisions
m
→{{header|Fōrmulæ}}
(→Insitux: inclusion) |
|||
(5 intermediate revisions by 5 users not shown) | |||
Line 502:
441
</pre>
=={{header|Binary Lambda Calculus}}==
Every BLC program uses higher order functions, since the parsed lambda term is applied to the remainder of input, which is, like everything in lambda calculus, itself a function. For example, the empty input is nil = <code>\x\y.y</code>. So the following minimal 4-bit BLC program passes nil to the identity function:
<pre>0010</pre>
=={{header|BQN}}==
Line 537 ⟶ 542:
p doit ->add 1 2 #prints 3</syntaxhighlight>
=={{header|Bruijn}}==
Everything in bruijn is a function (including strings and numbers), so even <syntaxhighlight lang="bruijn">main [0]</syntaxhighlight> would be a valid solution since the argument of <code>main</code> is already a functional encoding of stdin.
A more obvious example:
<syntaxhighlight lang="bruijn">
first [0 [[0]]]
second [first [[1]]]
:test (second) ([[[[0]]]])
</syntaxhighlight>
=={{header|Burlesque}}==
Line 1,252 ⟶ 1,269:
=={{header|Elena}}==
{{trans|Smalltalk}}
ELENA
<syntaxhighlight lang="elena">import extensions;
Line 1,258 ⟶ 1,275:
{
var first := (f => f());
var second := { ^ "second" };
console.printLine(first(second))
}</syntaxhighlight>
Line 1,600 ⟶ 1,617:
[[File:Fōrmulæ - Higher-order functions 11.png]]
Since the '''Apply twice''' function returns a function, it can be immediately invoked:
[[File:Fōrmulæ - Higher-order functions 12.png]]
[[File:Fōrmulæ - Higher-order functions 11.png]]
It can also take a pure symbol, in order to retrrieve a symbolic result:
[[File:Fōrmulæ - Higher-order functions 13.png]]
[[File:Fōrmulæ - Higher-order functions 14.png]]
=={{header|GAP}}==
Line 4,316 ⟶ 4,339:
=={{header|Wren}}==
<syntaxhighlight lang="
System.print("first function called")
f.call()
Line 4,330 ⟶ 4,353:
second function called
</pre>
=={{header|Z80 Assembly}}==
|