Function definition: Difference between revisions

add mul function definition in BLC
imported>RonReu
imported>Tromp
(add mul function definition in BLC)
Line 1,102:
 
print multiply(3, 2)</syntaxhighlight>
 
=={{header|Binary Lambda Calculus}}==
 
In lambda calculus, multiply on Church numerals is <code>mul = \m \n \f. m (n f)</code> which in BLC is
 
<syntaxhighlight>00 00 00 01 1110 01 110 10</syntaxhighlight>
 
If mul is used several times within an expression E, then they can share the same definition by using <code>(\mul. E)(\m\n\f. m (n f))</code>. For example, the cube function is <code>\n. (\mul. mul n (mul n n))(\m\n\f. m (n f))</code> which in BLC is
 
<syntaxhighlight>00 01 00 01 01 10 110 01 01 10 110 110 0000000111100111010</syntaxhighlight>
 
=={{header|BQN}}==
Anonymous user