linenoise repl...

This commit is contained in:
Lobo 2026-01-21 14:12:42 -03:00
parent d359c68c32
commit 54d12060ec
3 changed files with 12 additions and 39 deletions

View file

@ -1,25 +1,12 @@
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 }
"50 fib => " type
50 fib .
def times {
if: over 0 =
[drop drop]
[swap over >r >r call r> 1 - r> times];
}
\ We can also calculate the Fibonnaci numbers using the `times' combinator
\ we just implemented:
def fib-iter {
0 1 dig times: [dup [+] dip swap]; drop
def fib {
0 1 dig [dup [+] dip swap] times drop
}
"50 fib-iter => " type
50 fib-iter .
"50 fib => " type
50 fib .