title: How to iterate over an array with underscore.js having the previous value as well as the current?
body: <p>Is there any easy magical combination of functions from underscore (lo-dash) to achieve the following algorithm:</p>
  
  <pre><code>var arr = [1, 4, 9, 16, 25];
  var result = [];
  for(var i = 1, len = arr.length; i &lt; len; ++i) {
      var current = arr[i];
      var previous = arr[i-1];
      result[i-1] = current - previous;
  }
  // result == [3, 5, 7, 9]
  </code></pre>
  
  <p>with a simpler syntax:</p>
  
  <pre><code>var arr = [1, 4, 9, 16, 25];
  var result = _.???(arr, function(current, previous) {
      return current - previous;
  }
  </code></pre>
  
  <p>?</p>
  
  <p>Notes:</p>
  
  <ol>
  <li>that I don't want to roll my own function, I'd rather use a combination of existing methods.</li>
  <li>obviously my arrays contain objects not numbers and the result may or may not be a list of  numbers.</li>
  </ol>