Basic Parallel Reduction in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleReduceApplicationTest
    class Program
        public class ReduceSimple
            delegate T Func<T>(T arg0, T arg1);

            T Reduce<T>(T[] input, T seed, Func<T> r)
                T result = seed;
                foreach (T e in input)
                    result = r(result, e);
                return result;

            public void CheckReduce()
                int[] nums = new int[] { 1, 2, 5, 10, 1 };
                int sum = Reduce(nums, 0, (x, y) => x + y);
                int min = Reduce(nums, int.MaxValue, (x, y) => x < y ? x : y);
                int max = Reduce(nums, int.MinValue, (x, y) => x > y ? x : y);
                Console.WriteLine("Total Value=" + sum);
                Console.WriteLine("Max Value=" + max);
                Console.WriteLine("Min Value=" + min);

        static void Main(string[] args)
            Console.WriteLine("Simple Program to Demonstrate Parallel Reduction in C#");
            ReduceSimple p = new ReduceSimple();


  1. Exactly what these kinds of freight broker agent dispatcher training will not teach you can be the best way to actually work with no matter which software you determine to select. That in my opinion is very important to your accomplishment, and also the best part can be spots including internet vehicle stop one example is will probably teach you exactly how to use their software.


Post a Comment

Popular posts from this blog

ActiveMQ, easy to use open source message oriented middleware (MOM)

Basic Send Message to MQ with Java and IBM MQ JMS

Automated Service Monitoring with F5, Consul and Python F5 SDK