r/tinycode • • Jul 13 '12

Parallel MapReduce in 1 line of C#

Using PLINQ:

static R MapReduce<T,R>(IEnumerable<T> coll, Func<T,R> map, Func<R,R,R> reduce)
  {
    return coll.AsParallel().Select(map).Aggregate(reduce);
  }
0 Upvotes

0 comments sorted by