Voting

Category

esoteric language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Cω (C-Omega)

Date:08/25/08
Author:Halo_Four
URL:n/a
Comments:1
Info:http://research.microsoft.com/Comega/
Score: (3.00 in 7 votes)
using System;

class Program {
	static int* ReverseRange(int max, int min) {
		for(int i = max; i >= min; i--) {
			yield return i;
		}
	}
	
	public struct verse {
		public string part1;
		public string action;
		public string part2;
		public int index;
	}

    static void Main() {
		ReverseRange(99, 0).{
			if(it != 0) {
				string plural = it != 2 ? "s" : "";
				return <verse>
					<part1>{ return string.Format("{0} bottle{1} of beer", it, plural); }</part1>
					<action>Take one down and pass it around</action>
					<part2>{ return string.Format("{0} bottle{1} of beer", it - 1, plural); }</part2>
					<index>{ it }</index>
				</verse>;
			}
			else {
				return <verse>
					<part1>No more bottles of beer</part1>
					<action>Go to the store and buy some more</action>
					<part2>99 bottles of beer</part2>
					<index>{ it }</index>
				</verse>;
			}
		}.{
			Console.WriteLine("{0} on the wall, {0}", it.part1);
			Console.WriteLine("{0}, {1} on the wall", it.action, it.part2);
		};
		
        Console.ReadLine();
    }
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Luiz said on 11/12/08 00:25:53

Luiz Cool! C-Omega has a preview compiler already :D

I'll test it :)

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!

Name:

eMail:

URL:

Security Code:
  
Comment: