title: Java 8 generate stream of integer based on last value
body: <p>I need to generate stream of <strong>integers</strong> that each value is based on the value before according to some math function.</p>
  
  <p>For example - lets say I want to take last number and add 10:
  [1, 11, 21, 31, 41, ...]</p>
  
  <p>of course the real function is much more complex.</p>
  
  <p>I tried taking the fibonaci example but couldn't make it work:</p>
  
  <pre><code>Stream.iterate(new long[]{ 1, 1 }, p-&gt;new long[]{ p[1], p[0]+p[1] })
        .limit(92).forEach(p-&gt;System.out.println(p[0]));
  </code></pre>
  
  <p>I can only start at 1.</p>
  
  <p>This is what I tried doing:</p>
  
  <pre><code>Stream.iterate(new long[]{ 1 }, p-&gt; {p[0], p[0] + 10})
  .limit(4).forEach(p-&gt;System.out.println(p[0]));
  </code></pre>