diff options
Diffstat (limited to 'core.fth')
-rw-r--r-- | core.fth | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -111,4 +111,27 @@ swap postpone literal postpone literal ; imm : ." postpone s" state @ if ['] type compile, else type then ; imm -." hello world" +: move dup 0 <= if drop 2drop exit then + >r 2dup < r> swap if + 1- 0 swap do over i + c@ over i + c! -1 +loop + else + 0 do over i + c@ over i + c! loop + then 2drop ; +: fill -rot begin dup 0 > while + >r 2dup c! char+ r> 1- repeat + 2drop drop ; + +: environment? 2drop 1 0= ; + +: accept over >r begin dup 0 > while + key dup 32 < if 2drop 0 + else dup emit rot 2dup c! char+ swap drop swap 1- then + repeat drop r> - [ 1 chars ] literal / ; + +: recurse _compxt @ compile, ; imm + +: fib ( n1 -- n2 ) dup 1 > if 1- dup 1- recurse swap recurse + then ; + +: fibs 10 0 do i fib . loop cr ; + +fibs ." hello world" |