Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Forth

(original version)

Date:04/20/05
Author:Dan Reish
URL:n/a
Comments:0
Info:n/a
Score: (2.96 in 23 votes)
\ 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
;

: nbottles ( n -- )
  BEGIN  .bottles  ?dup NOT UNTIL
;

99 nbottles

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
ANS standardIan Osgood07/12/0512

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: