Man or boy test: Difference between revisions

Content added Content deleted
Line 2,205: Line 2,205:
print(a(10, K(1), K(-1), K(-1), K(1), K(0)))</lang>
print(a(10, K(1), K(-1), K(-1), K(1), K(0)))</lang>


=={{header|Mathematica}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==

This ''Mathematica'' code was derived from the Ruby example appearing below.
This ''Mathematica'' code was derived from the Ruby example appearing below.
<lang Mathematica>$RecursionLimit = 1665; (* anything less fails for k0 = 10 *)

$RecursionLimit = 1665; (* anything less fails for k0 = 10 *)
a[k0_, x1_, x2_, x3_, x4_, x5_] := Module[{k, b },
a[k0_, x1_, x2_, x3_, x4_, x5_] := Module[{k, b },
k = k0;
k = k0;
b = (k--; a[k, b, x1, x2, x3, x4]) &;
b = (k--; a[k, b, x1, x2, x3, x4]) &;
If[k <= 0, x4[] + x5[], b[]]]
If[k <= 0, x4[] + x5[], b[]]]
a[10, 1 &, -1 &, -1 &, 1 &, 0 &]</lang>

{{out}}
a[10, 1 &, -1 &, -1 &, 1 &, 0 &] (* => -67 *)
<pre>-67</pre>


=={{header|Modula-3}}==
=={{header|Modula-3}}==