99 bottles of beer: Difference between revisions

m
(submitted debug version with only 2 bottles)
Line 2,573:
 
=={{header|Elena}}==
ELENA 3.4.0 :
<lang elena>import system'routines.;
import extensions.;
import extensions'routines.;
import extensions'text.;
 
extension bottleOp
{
bottleDescription()
= self literal.Printable + (self != 1) .iif(" bottles"," bottle").;
bottleEnumerator() = Variable new:self; doWithVariable(self).doWith:(n)
[{
^ new Enumerator::
{
bool next() = n > 0.;
get() = StringWriter new; StringWriter()
.printLine(n .bottleDescription()," of beer on the wall");
.printLine(n .bottleDescription()," of beer");
.printLine("Take one down, pass it around");
.printLine((n .reduce:1) .bottleDescription()," of beer on the wall").;
reset() []{}
enumerable() = target.__target;
}
].};
}
 
public program()
{
[
var bottles := 99.;
bottles .bottleEnumerator; ().forEach:printingLn.
]}</lang>
{{out}}
<pre>
Anonymous user