News for hackers. Stuff that matters.
Re:C# functional language extensions and Erlang-like concurr... by louthy on Monday January 30, 2017 @05:47PM (#13525831)
Author here. When I started the project C#6 was just arriving. It's awesome to see the ValueTuples coming through for C#7. I have been adding some super-powers to them for lang-ext 2.0 (which is work in progress):

Example of extensions for ValueTuple<A,B,C> (there are extensions up to ValueTuple<A,B,C,D,E,F,G> and Tuple<A,B,C,D,E,F,G>)

https://github.com/louthy/language-ext/blob/type-classes/Lan...

It allows cool stuff like this:

    var abc = ('a', 'b').Add('c');                                           // ('a', 'b', 'c')
    var abcd = ('a', 'b').Add('c').Add('d');                                 // ('a', 'b', 'c', 'd')
    var abcd5 = ('a', 'b').Add('c').Add('d').Add(5);                         // ('a', 'b', 'c', 'd', 5)

    var sumA = (1, 2, 3).Sum<TInt, int>();                                   // 6
    var sumB = (2, 4, 8).Product<TInt, int>();                               // 64
    var flag = ("one", "two", "three").Contains<TString, string>("one");     // true
    var str = ("Hello", " ", "World").Concat<TString, string>();             // "Hello World"
    var list = (List(1, 2, 3), List(4, 5, 6)).Concat<TLst<int>, Lst<int>>(); // [1,2,3,4,5,6]

There are no comments on this comment yet.