home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
p4_1bs.seq
< prev
next >
Wrap
Text File
|
1990-02-01
|
899b
|
45 lines
\ Balraj Sidhu Set: 14D4
\ Comp 462 - Forth
\ Date: April 10, 1990
\ Problem 4.1
: stars1 ( n -- )
?dup if 0 do ascii * emit loop then ;
: stars2 ( n -- )
0 ?do ascii * emit loop ;
: stars3 ( n -- )
0 do ascii * emit loop ;
: starhv ( n -- )
?dup if
dup 0<
if
cr abs 0 do ascii * emit cr loop
else
cr 0 do ascii * emit loop
then cr
then ;
COMMENT:
Part a)
-------
If the above definition (stars3) is ran with a 0 passed to it, it would
execute the loop 65535 times. This is because the loop word increments
the count before it does the check to see if it matched the ending count.
Part b)
------
Executing the above definitons with -1 causes the programs to loop 65534
times.
COMMENT;