日期:2014-05-17 浏览次数:21159 次
let add x y = x + y
let mutable i = add 3 4
printfn "%d" i
let addTen x = add 10 x
let mutable i = add 3 4
let mutable j = addTen i
printfn "%d" j
let eval x y z = y x z
let add x y = x + y
let mutable i = eval 3 add 5
printfn "%d" i
let eval x y z = y x z
let sub x y = x - y
let mutable i = eval 8 sub 1
printfn "%d" i
let outputArray = Array.iter (fun x -> printfn "%d" x)
outputArray [| 1; 2; 3; 4; 5 |]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Func<Func<int, int, bool>, Func<int[], int[]>> filter =
x => new Func<int[], int[]>(y => y.Skip(1).Where(z => x(y[0], z)).ToArray());
Func<int[], int[]> qsort = x => x;
Func<int[], int[]> lesser = dt => filter((x, y) => y < x)(dt);
Func<int[], int[]> greater = dt => filter((x, y) => y >= x)(dt);
&nbs