Y combinator: Difference between revisions

Content deleted Content added
Marvin (talk | contribs)
Add bruijn
Line 1,229: Line 1,229:
fib(9)=34
fib(9)=34
fib(10)=55</pre>
fib(10)=55</pre>

=={{header|Bruijn}}==
As defined in <code>std/Combinator</code>:
<syntaxhighlight lang="bruijn">
:import std/Number .

# sage bird combinator
y [[1 (0 0)] [1 (0 0)]]

# factorial using y
factorial y [[=?0 (+1) (0 ⋅ (1 --0))]]

:test ((factorial (+6)) =? (+720)) ([[1]])

# (very slow) fibonacci using y
fibonacci y [[0 <? (+1) (+0) (0 <? (+2) (+1) rec)]]
rec (1 --0) + (1 --(--0))

:test ((fibonacci (+6)) =? (+8)) ([[1]])
</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==