domingo, 17 de julio de 2011

Mono 2.12 is out but ...

GGC SaysIn this version is there WCF support to work ...


Icaza SaysWCF remains a technology under development, and we strongly advise users to pick alternative technologies like Protocol Buffers.

Mono C# and LINQ

Here a little of code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 0, 4, 2, 6, 3, 8, 3, 1 };
            var result = from n in nums
                         where n < 5
                         orderby n
                         select n;
            foreach (int i in result)
                Console.WriteLine(i);

            Console.WriteLine();

            var result1 = nums.Where(n => n < 5).OrderBy(n => n);

            foreach (int i in result1)
                Console.WriteLine(i);

            Console.WriteLine();

            var result2 = nums
                .Where(n => n < 5)
                .OrderBy(n => n);

            foreach (int i in result2)
                Console.WriteLine(i);

            Console.ReadLine();
        }
    }
}

Compile with:

gmcs your_file_in_csharp.cs


And see the output.

Ruby VS C#


Ruby equivalent of C# Linq Aggregate method


You have this code in C#:
var factorial = new[] { 1, 2, 3, 4, 5 }.Aggregate((acc, i) => acc * i)

And Ruby responses:
factorial = (1..5).reduce(:*)
or maybe
factorial = 1.upto(5).reduce(:*)
or
factorial = [1, 2, 3, 4, 5].reduce(:*)
More info:
http://stackoverflow.com/questions/5036836/ruby-equivalent-of-c-linq-aggregate-method