Language SML
| Date: | 04/20/05 |
| Author: | Norvald |
| URL: | n/a |
| Comments: | 2 |
| Info: | n/a |
| Score: |
(* 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
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!
Comments
(*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"
Greetz,
Sebastian
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.