repo.or.cz
/
factor
/
jcg.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Fix $or
[factor/jcg.git]
/
extra
/
benchmark
/
fib4
/
fib4.factor
blob
c988e5722e6c693762f0e3bf648bf13c12fb5215
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