Language Fantom
Date: | 12/12/10 |
Author: | Per Pettersson |
URL: | n/a |
Comments: | 0 |
Info: | http://fantom.org |
Score: | (3.00 in 3 votes) |
class Beer { Void main() { (99..0).each |n| { echo(verse(n) + "\n") } } Str verse(Int n) { q := quantStr(n) qq := quantStr(n == 0 ? 99 : n - 1) s := suffix(n) ss := suffix(n == 0 ? 99 : n - 1) lastPart := n > 0 ? "Take one down and pass it around" : "Go to the store and buy some more" return "$q bottle$s of beer on the wall, $q.lower bottle$s of beer. $lastPart, $qq bottle$ss of beer on the wall." } Str suffix(Int n) { n == 1 ? "" : "s" } Str quantStr(Int n) { n == 0 ? "No more" : n.toStr } }
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