// more perverse examples abstract class C1[T] { public abstract getT () : T } class C2[X] : C1[X -> void] { public override getT () : X -> void { x => System.Console.WriteLine (x) } } class D1[T] { public getT () : T -> void { x => System.Console.WriteLine (x) } } class D2[X] : D1[X * X] { } // end of perverse examples class A[T] { public CreateFunction() : T->void { fun (a) { System.Console.WriteLine (a) } } } def cache[A,R](func : A -> R) : A -> R { def map = System.Collections.Generic.Dictionary.[A,R](); args => if (map.ContainsKey(args)) map[args] else { def result = func(args); map[args] = result; result } } def a = A.[int*int](); def f = a.CreateFunction(); f(1, 2); mutable ack; ack = (a, b) => if (b == 0) ack(a - 1, 1) else if (a == 0) b + 1 else ack(a - 1, ack(a, b - 1)); ack = cache(ack); System.Console.WriteLine(ack(3,9)); C2().getT()(4,2); D2().getT()(4,2); mutable water = 1; def fire = fun { System.Console.WriteLine (water) }; water = 2; fire (); water = 4; fire (); /* BEGIN-OUTPUT (1, 2) 4093 (4, 2) (4, 2) 2 4 END-OUTPUT */