real language

## Language Wrapl

 Date: 12/30/06 Author: Raja Mukherji URL: http://wrapl.sf.net Comments: 0 Info: http://wrapl.sf.net Score: (3.00 in 99 votes)
```mod bottles;

imp std.io.terminal use Out;

def tens <- [
"", "Twenty", "Thirty", "Forty", "Fifty",
"Sixty", "Seventy", "Eighty", "Ninety"
];

def ones <- [
"one", "two", "three", "four", "five",
"six", "seven", "eight", "nine"
];

def small <- [
"One", "Two", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten",
"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen",
"Sixteen", "Seventeen", "Eighteen", "Nineteen"
];

def words(N) (
--	If 0 < N < 20 then we use the simple number small[N].
--	If N > 20 then small[N] fails so we try a compound number.
--	ones[N % 10] will fail for N a multiple of 10 so we just use the tens string in this case.
--	If N = 0 then tens[N / 10] will fail so we get "No more".
ret (small[N] | (tens[N / 10] + ((" " + ones[N % 10]) | "")) | "No more") +
--	If N = 1 then " bottle of beer" otherwise " bottles of beer".
(N = 1 => " bottle of beer" // " bottles of beer")
);

var I <- 99;
var Words <- words(I);
rep (
Out:write(Words + " on the wall,\n");
Out:write(Words + ",\n");
Out:write("You take one down and pass it around,\n");
Words <- words(I <- \$ - 1);
Out:write(Words + " on the wall.\n");
Out:write("\n");
until I = 0;
);```

## Alternative Versions

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.