Language Unicon
| Date: | 04/19/06 |
| Author: | Christian Meurin |
| URL: | n/a |
| Comments: | 5 |
| Info: | http://unicon.sourceforge.net/ |
| Score: |
# Unicon is a "unified extended dialect" of the Icon programming language.
# It introduces modern features such as object orientation and such.
# Unicon is the successor of Idol, an earlier attempt at Icon OOP.
# The current source code has been left alone for nearly 2 years, so
# I'm not sure if this is still in development.
#
# http://unicon.sourceforge.net/
package bottlesofbeer
$define BEERMAX 99
$define LOWBEER 1
$define NOBEER 0
class BeerSong()
method start_chugging()
local beercount
beercount := BEERMAX;
while beercount >= NOBEER do {
# this could be slightly mistyped, but I'm not sure
if beercount not LOWBEER then {
write (beercount, " bottles of beer on the wall,\n");
write (beercount, " bottles of beer.\n");
} else {
write ("One more bottle of beer on the wall,\n");
write ("One more bottle of beer.\n");
}
write ("Take one down, pass it around,\n");
case beercount of {
0 : write ("No more bottles of beer on the wall.\n")
1 : write ("One more bottle of beer on the wall.\n")
default : write (beercount, " more bottles of beer on the wall.\n")
}
}
write ("Get out of my bar yeh drunk low life!\n");
end
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
while beercount >= LOWBEER do {
I entered the NOBEER constant, oops!
the fact that once the syntax error is fixed and a main procedure
is added, it's an infinite loop. Here's a variant that works
(he claims), although it also uses a few more esoteric features
of Unicon:
procedure main(args)
numBeers := integer(args[1]) | 99
BeerSong().start_chugging(numBeers)
end
class BeerSong()
method start_chugging(beerMax)
local beerCount
every beerCount := beerMax to 1 by -1 do {
write( (beerCount = 1, "One bottle"
" of beer on the wall,"
write( (beerCount = 1, "One bottle"
" of beer."
write("Take one down, pass it around,"
write(case beerCount of {
1 : "No more bottles"
2 : "One more bottle"
default : (beerCount-1)||" more bottles"
}," of beer on the wall.\n"
}
end
end
Quick test (sorry, I don't see any instructions):
<pre>
# this is a comment
</pre>
in turn, is a successor to SNOBOL4.