Exemplo n.º 1
0
 /// <summary>
 /// See also https://msdn.microsoft.com/en-us/library/bb549218(v=vs.110).aspx
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="input"></param>
 /// <param name="initial"></param>
 /// <param name="func"></param>
 /// <returns></returns>
 public static Bag <T> Aggregate <T>(this Bag <T> input, T initial, Func <T, T, T> func)
 => input
 .DisjointUnion(initial.ToBag())
 .Select(i => new Void().WithValue(i))
 .GroupBy(func)
 .Select(i => i.Value);