Posted by: leppie | October 27, 2009

IronScheme and C# 4′s new dynamic keyword

So everyone (well all the IronXXX people) is doing it, so I might well too :)

I present using IronScheme in C# 4:

class Program
{
  static dynamic Scheme = new SchemeEnvironment();

  static void Main(string[] args)
  {
    var list = Scheme.list;
    var map = Scheme.map;
    var reverse = Scheme.reverse;

    Func<int, int> f = x => x * x;

    var r = map(f, reverse(map(f, list(1, 2, 3))));

    Console.WriteLine(r.car); // prints 81
  }
}

The implementation is straight forward, and can be viewed here. I just involves a simple Linq expression. :)

Cheers

leppie

About these ads

Responses

  1. LOL @ “static dynamic”

    • I was thinking exactly the same when I wrote it.

  2. Something new about silverlight support?

    • Nope, sorry.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: