adjacent_difference

Computed the adjacent difference in a sequence of numbers.

  template <class InputIterator, 
  class OutputIterator>
  OutputIterator adjacent_difference
  (InputIterator first, InputIterator last,
  OutputIterator result);
  template <class InputIterator, 
  class OutputIterator, class BinaryOperation>
  OutputIterator adjacent_difference
  (InputIterator first, InputIterator last,
  OutputIterator result,
  BinaryOperation binary_op);
  

The first computes the adjacent difference and sends it to the output iterator argument.

x, y, z

x, y-x, z-y.

The second form computes according to the operational argument and sends it to the output iterator argument. For example if the operational argument was a division operation

x, y, z

x, y/x, z/y

Remarks

The range as the result plus the last minus the first.