title: Subtracting the current and previous item in a list
body: <p>It is very common to write a loop and remember the previous.</p>
  
  <p>I want a generator that does that for me. Something like:</p>
  
  <pre><code>import operator
  
  def foo(it):
      it = iter(it)
      f = it.next()
      for s in it:
          yield f, s
          f = s
  </code></pre>
  
  <p>Now subtract pair-wise.</p>
  
  <pre><code>L = [0, 3, 4, 10, 2, 3]
  
  print list(foo(L))
  print [x[1] - x[0] for x in foo(L)]
  print map(lambda x: -operator.sub(*x), foo(L)) # SAME
  </code></pre>
  
  <p><strong>Outputs:</strong></p>
  
  <pre><code>[(0, 3), (3, 4), (4, 10), (10, 2), (2, 3)]
  [3, 1, 6, -8, 1]
  [3, 1, 6, -8, 1]
  </code></pre>
  
  <ul>
  <li>What is a good name for this operation?</li>
  <li>What is a better way to write this?</li>
  <li>Is there a built-in function that does something similar?</li>
  <li>Trying to use 'map' didn't simplify it. What does?</li>
  </ul>