home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p2_4dc.seq < prev    next >
Encoding:
Text File  |  1990-03-28  |  537 b   |  24 lines

  1. \ COUNTING PROGRAM FOR P2.4
  2.  
  3. \ Author: Dickson Cheng  03/28/90 13:31:54.29
  4.  
  5. : COUNT_UP      ( n -- )
  6.         1+ 0 ?DO CR I . LOOP ;
  7.  
  8. : COUNT_UP_BY   ( n inc -- )
  9.         SWAP 1+ 0 ?DO CR I . DUP +LOOP DROP ;
  10.  
  11. : COUNT_DOWN    ( n -- )
  12.         0 SWAP ?DO CR I . -1 +LOOP ;
  13.  
  14. : COUNT_DOWN_BY ( n dec -- )
  15.         NEGATE 0 ROT ?DO CR I . DUP +LOOP DROP ;
  16.  
  17. : MESSAGE       ( -- )
  18.         DARK CR ." Usage:
  19.         CR ." n COUNT_UP       n inc COUNT_UP_BY"
  20.         CR ." n COUNT_DOWN     n dec COUNT_DOWN_BY" ;
  21.  
  22. MESSAGE
  23.  
  24.