Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/examples/bottles.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ Forth version of the 99 Bottles program.
\ Dan Reish, dreish@izzy.net

: .bottles ( n -- n-1 )
   dup 1 = IF  ." One bottle of beer on the wall," CR
           ." One bottle of beer," CR
           ." Take it down," 
   ELSE  dup . ." bottles of beer on the wall," CR
     dup . ." bottles of beer," CR
     ." Take one down," 
   THEN
   CR
   ." Pass it around," CR
   1-
   DUP IF DUP 1 = IF  ." One bottle of beer on the wall;" 
        ELSE  dup . ." bottles of beer on the wall;" 
        THEN
    ELSE  ." No more bottles of beer on the wall." 
   THEN
   CR
;

: bottles ( n -- )
  BEGIN  .bottles DUP 0= UNTIL DROP
;

99 bottles

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.