factor/extra/benchmark/fib4/fib4.factor

23 lines
427 B
Factor
Raw Normal View History

2008-08-30 21:38:07 -04:00
USING: accessors math kernel debugger ;
2007-09-20 18:09:08 -04:00
IN: benchmark.fib4
TUPLE: box { i read-only } ;
2007-09-20 18:09:08 -04:00
C: <box> box
: tuple-fib ( m -- n )
2008-08-30 21:38:07 -04:00
dup i>> 1 <= [
2007-09-20 18:09:08 -04:00
drop 1 <box>
] [
i>> 1 - <box>
2007-09-20 18:09:08 -04:00
dup tuple-fib
swap
i>> 1 - <box>
2007-09-20 18:09:08 -04:00
tuple-fib
2008-08-30 21:38:07 -04:00
swap i>> swap i>> + <box>
] if ; inline recursive
2007-09-20 18:09:08 -04:00
: fib4-benchmark ( -- ) T{ box f 34 } tuple-fib i>> 9227465 assert= ;
2007-09-20 18:09:08 -04:00
MAIN: fib4-benchmark