Currying: Difference between revisions
m
→{{header|Binary Lambda Calculus}}
No edit summary |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 464:
bc
bcde</pre>
=={{header|Binary Lambda Calculus}}==
In BLC, all multi argument functions are necessarily achieved by currying, since lambda calculus functions (lambdas) are single argument. A good example is the Church numeral 2, which given a function f and an argument x, applies f twice on x: C2 = \f. (\x. f (f x)). This is written in BLC as
<pre>00 00 01 110 01 110 01</pre>
where 00 denotes lambda, 01 denotes application, and 1^n0 denotes the variable bound by the n'th enclosing lambda. Which is all there is to BCL!
=={{header|BQN}}==
Line 637 ⟶ 645:
=={{header|EchoLisp}}==
[[EchoLisp]] has native support for curry, which is implemented thru closures, as shown in [[
<syntaxhighlight lang="text">
;;
Line 1,713 ⟶ 1,721:
Out[5]:= 5
</pre>
=={{header|MiniScript}}==
{{trans|Rust}}
<syntaxhighlight lang="miniscript">addN = function(n)
f = function(x)
return n + x
end function
return @f
end function
adder = addN(40)
print "The answer to life is " + adder(2) + "."</syntaxhighlight>
{{out}}
<pre>The answer to life is 42.</pre>
=={{header|Nemerle}}==
Line 2,456 ⟶ 2,479:
=={{header|Wren}}==
{{trans|Rust}}
<syntaxhighlight lang="
var adder = addN.call(40)
|