mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
183c5bae38
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
18 lines
No EOL
259 B
Forth
18 lines
No EOL
259 B
Forth
# example|RecursiveFibonacci
|
|
|
|
Declare module constant (prevents reloading when using `import`):
|
|
|
|
````
|
|
:example|RecursiveFibonacci ;
|
|
````
|
|
|
|
----
|
|
|
|
````
|
|
:fib (n-m)
|
|
dup
|
|
[ n:zero? ] [ #1 eq? ] bi or
|
|
not 0; drop
|
|
[ n:dec fib ] sip
|
|
[ #2 - fib ] call + ;
|
|
```` |