]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/fib4/fib4.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / benchmark / fib4 / fib4.factor
1 USING: accessors math kernel debugger ;
2 IN: benchmark.fib4
3
4 TUPLE: box { i read-only } ;
5
6 C: <box> box
7
8 : tuple-fib ( m -- n )
9     dup i>> 1 <= [
10         drop 1 <box>
11     ] [
12         i>> 1 - <box>
13         dup tuple-fib
14         swap
15         i>> 1 - <box>
16         tuple-fib
17         swap i>> swap i>> + <box>
18     ] if ; inline recursive
19
20 : fib-main ( -- ) T{ box f 34 } tuple-fib i>> 9227465 assert= ;
21
22 MAIN: fib-main