Language Unicon
Date: | 04/19/06 |
Author: | Christian Meurin |
URL: | n/a |
Comments: | 5 |
Info: | http://unicon.sourceforge.net/ |
Score: | (3.01 in 118 votes) |
# 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
Christian Meurin said on 04/22/06 21:20:56
Slight fix:
while beercount >= LOWBEER do {
I entered the NOBEER constant, oops!
Steve Wampler said on 01/28/09 17:20:33
There are a few minor problems with the above code - including
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"| (beerCount || " bottles",
" of beer on the wall,"
write( (beerCount = 1, "One bottle"| (beerCount || " bottles",
" 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
Steve Wampler said on 01/28/09 17:25:35
Sigh. Obviously I don't know the format for embedding code...
Quick test (sorry, I don't see any instructions):
<pre>
# this is a comment
</pre>
khalida said on 06/16/09 10:39:11
Steve Wampler said on 01/12/10 17:26:29
No, Unicon is not the same as ADL. Unicon is a successor to Icon which,
in turn, is a successor to SNOBOL4.