title: Iterable Sum in Java?
body: <p>Is there a library that does this:</p>
  
  <pre><code>public class Iterables{
      private Iterables() {}
  
      public static &lt;T&gt; int sum(Iterable&lt;T&gt; iterable, Func&lt;T, Integer&gt; func) {
          int result = 0;
          for (T item : iterable)
              result += func.run(item);
          return result;
      }
  }
  
  public interface Func&lt;TInput, TOutput&gt; {
      TOutput run(TInput input);
  }
  </code></pre>