Language Nemerle
(ext. methods and foreach)
Date: | 06/20/06 |
Author: | Vermicious Knid |
URL: | n/a |
Comments: | 0 |
Info: | http://nemerle.org |
Score: | (2.97 in 30 votes) |
using System; module StringExt { public Capitalize(this s : string) : string { Char.ToUpper(s[0]).ToString() + s.Substring(1) } } def beers(n) { | 0 => "no more bottles of beer" | 1 => "1 more bottle of beer" | _ => $"$n bottles of beer" } def onTheWall = n => $"$(beers(n)) on the wall, $(beers(n)).\n"; def passAround(n) { | 0 => $"Go to the store and buy some more, $(beers(99)) on the wall.\n" | _ => $"Take one down and pass it around, $(beers(n-1)) on the wall.\n" } foreach(n in [99, 98 .. 0]) Console.WriteLine(onTheWall(n).Capitalize() + passAround(n))
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
up-to-date version | Vermicious Knid | 06/20/06 | 0 | |
2 | caminoix | 09/13/05 | 2 | |
english numerals | Vermicious Knid | 06/20/06 | 0 |
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