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 SML

Date:04/20/05
Author:Norvald
URL:n/a
Comments:2
Info:n/a
Score: (3.01 in 113 votes)
(* SML version of 99 bottles of beer *)
(* written by Norvald - norvald@hsr.no *)
let
    val itoa = Makestring.intToStr
    fun getabeer 0 = (print "Go to the store and buy some more,\n";
		      print "99 bottles of beer on the wall.\n")
      | getabeer 1 = (print "1 bottle of beer on the wall,\n";
		      print "1 bottle of beer,\n";
		      print "Take one down, pass it around,\n";
		      print "0 bottle of beer on the wall.\n\n";
		      getabeer (0)) 
      | getabeer x = (print (itoa(x)^" bottles of beer on the wall,\n"); 
		      print (itoa(x)^" bottles of beer,\n");
		      print "Take one down, pass it around,\n";
		      print (itoa(x-1)^" bottles of beer on the wall.\n\n");
		      getabeer (x-1)) 
in
    getabeer 99;
end

Download Source | Write Comment

Alternative Versions

Comments

>>  Sebastian Ohlmann said on 05/22/05 18:22:23

Sebastian Ohlmann Hi, I wrote a minimal SML program:

(*SML Minimal Version of 99 bottles of beer
by Sebastian Ohlmann - 1 march 2005*)
val _=app(fn a=>print let val(b,c,d,e)=(" bottle(s)of beer"," on the wall\n",Int.toString,"\n";)in d a^b^c^d a^b^e^"take one down, pass it around,"^e^d(a-1)^b^c^e end)(rev(List.tabulate(99,fn f=>f+1)))

Greetz,
Sebastian

>>  kumar said on 12/07/07 07:27:58

kumar Hi,
I got some errors in this program. can any one fix it please let me know.
error i got is, when i used this code it prompts = in the next line so o gave semi colon.it repeated twice and after that it dsiplays the error semicolon end semicolon.

can i know how can i exactly execute this program in sml.
i appriciate your help.

thanks.

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: