*
This commit is contained in:
parent
1185690ce6
commit
b9a5bc5e63
9 changed files with 203 additions and 30 deletions
16
test.grr
16
test.grr
|
|
@ -1,15 +1,13 @@
|
|||
def over { swap dup >r swap r> }
|
||||
def dip { swap >r call r> }
|
||||
def keep { over >r call r> }
|
||||
def if { ? call }
|
||||
|
||||
def fac {
|
||||
dup if: 1 <= [drop 1] [dup 1 - fac *];
|
||||
def fib/aux {
|
||||
if: dig dup 0 =
|
||||
[drop drop]
|
||||
[bury [swap 1 - swap] dip dup [+] dip swap fib/aux]
|
||||
;
|
||||
}
|
||||
def fib { 0 1 fib/aux }
|
||||
|
||||
def fib {
|
||||
dup if: 1 <= [] [dup 1 - fib swap 2 - fib +];
|
||||
}
|
||||
|
||||
[ 20 fib ] call \=> 6765
|
||||
[ 10 fac ] call \=> 3628800
|
||||
[ 50 fib ] call \=> 12586269025
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue