// OPTIONS: -t:library #pragma indent using System.Console using Nemerle.Collections public class A public v : int public this (v : int) this.v = v public foo () : void Write ("foo()\n") [Record] \ public class C : A x : string namespace SomeDeepNamespace public class OtherwiseUnusedClass public static ToList2[T] (this a : array [T]) : list [T] List.FromArray (a) public class Abc public static Where [T] (this c : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : list[T] $[ e | e in c, fn (e) ] public class Bcd[T] public static NoWhere (this c : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : list[T] $[ e | e in c, ! fn (e) ] public class B public static foo (this a : A, p : int) : void Write ($"foo($(a.v),$p)\n") public static bar[A,B] (this a : G[A,B]) : void a.Describe () public static bar[A,B,C] (this a : G[A,B], _c : C) : void a.Describe () System.Console.WriteLine ($"$(typeof(C))") public static Rev [T] (this a : array [T]) : void foreach (i in [0 .. a.Length / 2]) a [i] <-> a [a.Length - i - 1] public static Run () : void def a = A (42) a.foo () a.foo (1) B.foo (a, 2) def c = C(77, "aa") c.foo (3) B.foo (c, 4) def g = G.[int,string]() g.Describe () g.bar () g.bar (7.0) def a = array [3, 14, 15] a.Rev () System.Console.WriteLine (List.FromArray (a)) B.Rev (a) System.Console.WriteLine (List.FromArray (a)) def a = array [1,2,3]; System.Console.WriteLine (a.Where(_ > 1)); def a = array ["foo", "bar", "foox"]; System.Console.WriteLine (a.Where(_.StartsWith ("fo"))); System.Console.WriteLine (a.NoWhere(_.StartsWith ("fo"))); public class G[X, Y] public Describe () : void System.Console.WriteLine ($"$(typeof(X)) $(typeof(Y))")