How to resolve the algorithm 99 bottles of beer step by step in the Golo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm 99 bottles of beer step by step in the Golo programming language
Table of Contents
Problem Statement
Display the complete lyrics for the song: 99 Bottles of Beer on the Wall.
The lyrics follow this form: ... and so on, until reaching 0 (zero). Grammatical support for 1 bottle of beer is optional. As with any puzzle, try to do it in as creative/concise/comical a way as possible (simple, obvious solutions allowed, too).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm 99 bottles of beer step by step in the Golo programming language
Source code in the golo programming language
module Bottles
augment java.lang.Integer {
function bottles = |self| -> match {
when self == 0 then "No bottles"
when self == 1 then "One bottle"
otherwise self + " bottles"
}
}
function main = |args| {
99: downTo(1, |i| {
println(i: bottles() + " of beer on the wall,")
println(i: bottles() + " of beer!")
println("Take one down, pass it around,")
println((i - 1): bottles() + " of beer on the wall!")
println("--------------------------------------")
})
}
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the Perl programming language
You may also check:How to resolve the algorithm Quaternion type step by step in the Picat programming language
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Concurrent computing step by step in the Java programming language
You may also check:How to resolve the algorithm Percolation/Mean cluster density step by step in the Tcl programming language