/// <summary> /// See also https://msdn.microsoft.com/en-us/library/bb549393(v=vs.110).aspx /// </summary> /// <typeparam name="K"></typeparam> /// <typeparam name="T"></typeparam> /// <param name="input"></param> /// <param name="key"></param> /// <param name="reduce"></param> /// <returns></returns> public static Bag <KeyValuePair <K, T> > GroupBy <K, T>( this Bag <T> input, Func <T, K> key, Func <T, T, T> reduce) => input.GroupBy(key, v => v, reduce);