F# / C# - from Chris Smith's Blog on F# tutorial .....
F# Code
#light
let square x = x * x
let numbers = [1 .. 10]
let squares = List.map square numbers
printfn "N^2 = %A"squares
open System
Console.ReadKey(true)
C# Code
using System;
using System.Linq;
class Program
{
static void Main()
{
Func
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var squares = numbers.Select(square);
Console.WriteLine("N^2 = {0}", squares.Aggregate("", (s, i) => s + " " + i));
Console.ReadKey(true);
}
}
Comments