title: Finding function minimum over range of arguments
body: <p>Let's assume I have:</p>
  
  <pre><code>int x = 5;
  int y = 10;
  </code></pre>
  
  <p>and a function with signature</p>
  
  <pre><code>public double CalculateEntropySplittingOnFeature(List&lt;Sample&gt; samples, int cutOffPoint) 
  </code></pre>
  
  <p>I want to find for which integer value between 5 and 0 included my function returns the lowest value. My solution:</p>
  
  <pre><code>((List &lt;Integer&gt;) IntStream.range(x, y))
                  .stream()
                  .min(new Comparator&lt;Integer&gt;() {
                      @Override
                      public int compare(Integer o1, Integer o2) {
                          return Double.compare(CalculateEntropySplittingOnFeature(samples, o2), CalculateEntropySplittingOnFeature(samples, o1));
                      }
                  });
  </code></pre>
  
  <p>But, I feel like there's a better/more elegant(/efficient) solution than generating an IntStream and casting it to list to then stream it again... Any advice?</p>