title: How to use Java 8 streams to find all values preceding a larger value?
body: <h1>Use Case</h1>
  
  <p>Through some coding Katas posted at work, I stumbled on this problem that I'm not sure how to solve.</p>
  
  <blockquote>
    <p>Using Java 8 Streams, given a list of positive integers, produce a
    list of integers where the integer preceded a larger value.</p>
  
  <pre><code>[10, 1, 15, 30, 2, 6]
  </code></pre>
    
    <p>The above input would yield:</p>
  
  <pre><code>[1, 15, 2]
  </code></pre>
    
    <p>since 1 precedes 15, 15 precedes 30, and 2 precedes 6.</p>
  </blockquote>
  
  <h2>Non-Stream Solution</h2>
  
  <pre><code>public List&lt;Integer&gt; findSmallPrecedingValues(final List&lt;Integer&gt; values) {
  
      List&lt;Integer&gt; result = new ArrayList&lt;Integer&gt;();
      for (int i = 0; i &lt; values.size(); i++) {
          Integer next = (i + 1 &lt; values.size() ? values.get(i + 1) : -1);
          Integer current = values.get(i);
          if (current &lt; next) {
              result.push(current);
          }
      }
      return result;
  }
  </code></pre>
  
  <h2>What I've Tried</h2>
  
  <p>The problem I have is I can't figure out how to access next in the lambda.</p>
  
  <pre><code>return values.stream().filter(v -&gt; v &lt; next).collect(Collectors.toList());
  </code></pre>
  
  <h2>Question</h2>
  
  <ul>
  <li>Is it possible to retrieve the next value in a stream?</li>
  <li>Should I be using <code>map</code> and mapping to a <code>Pair</code> in order to access next?</li>
  </ul>