title: Generic Map/Reduce List Extensions in C#
body: <p>I am writing a few extensions to mimic the map and reduce functions in Lisp.</p>
  
  <pre><code>public delegate R ReduceFunction&lt;T,R&gt;(T t, R previous);
  public delegate void TransformFunction&lt;T&gt;(T t, params object[] args);
  
  public static R Reduce&lt;T,R&gt;(this List&lt;T&gt; list, ReduceFunction&lt;T,R&gt; r, R initial)
  {
       var aggregate = initial;
       foreach(var t in list)
           aggregate = r(t,aggregate);
  
       return aggregate;
  }
  public static void Transform&lt;T&gt;(this List&lt;T&gt; list, TransformFunction&lt;T&gt; f, params object [] args)
  {
      foreach(var t in list)
           f(t,args);
  }
  </code></pre>
  
  <p>The transform function will cut down on cruft like:</p>
  
  <pre><code>foreach(var t in list)
      if(conditions &amp;&amp; moreconditions)
          //do work etc
  </code></pre>
  
  <p>Does this make sense? Could it be better?</p>