home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
pd6.lzh
/
TST
/
debugger.tst
< prev
next >
Wrap
Text File
|
1989-12-21
|
884b
|
66 lines
.( Loading Debugger test...) cr
#include debugger.f83
debugger
.( 1: Define a debuggable tail-recursive function) cr
: foo ( n -- )
?dup if ." foo " 1- tail-recurse else cr then ;
12 foo
trace foo
12 foo
.profile
.( 2: Redefine it as a recursive function) cr
: fie ( n -- )
?dup if ." fie " 1- recurse else cr then ;
12 fie
trace fie
12 fie
.profile
.( 3: Run the break point function) cr
( Only in interactive mode
break foo
10 foo a .s cr
10 foo c .s cr
10 foo e r .s cr
)
.( 4: Fibonanci number function; recursive and tail recursive) cr
: fib ( n -- m)
dup 1 > if dup 1- recurse swap 2- recurse + then ;
trace fib
10 fib . cr
.profile
: fib-tail ( a b c -- m)
?dup if 1- rot rot over + swap rot tail-recurse else swap drop then ;
: fib-iter ( n -- m)
1 0 rot fib-tail ;
trace fib-tail
trace fib-iter
20 fib-iter . cr
.profile
forth only