home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p4_1bs.seq < prev    next >
Text File  |  1990-02-01  |  899b  |  45 lines

  1. \ Balraj Sidhu   Set: 14D4
  2. \ Comp 462 - Forth
  3. \ Date: April 10, 1990
  4. \ Problem 4.1
  5.  
  6. : stars1 ( n -- )
  7.         ?dup if 0 do ascii * emit loop then ;
  8.  
  9. : stars2 ( n -- )
  10.         0 ?do ascii * emit loop ;
  11.  
  12. : stars3 ( n -- )
  13.         0 do ascii * emit loop ;
  14.  
  15. : starhv ( n -- )
  16.         ?dup if
  17.                 dup 0<
  18.                 if
  19.                         cr abs 0 do ascii * emit cr loop
  20.                 else
  21.                         cr 0 do ascii * emit loop
  22.                 then cr
  23.         then ;
  24. COMMENT:
  25.  
  26. Part a)
  27. -------
  28.  
  29. If the  above definition (stars3) is ran with a 0 passed to it, it would
  30. execute the loop 65535 times.  This is because the loop word increments
  31. the count before it does the check to see if it matched the ending count.
  32.  
  33. Part b)
  34. ------
  35.  
  36. Executing the above definitons with -1 causes the programs to loop 65534
  37. times.
  38.  
  39.  
  40. COMMENT;
  41.  
  42.  
  43.  
  44.  
  45.