Robert Klemme wrote:

> There is a subtlety: with your code there will be no previous for the 
> first element.  Depending on what the OP needs you can as well do
> 
> irb(main):001:0> (1..5).inject(nil) {|prev,curr| p [prev,curr];curr}
> [nil, 1]
> [1, 2]
> [2, 3]
> [3, 4]
> [4, 5]
> => 5
> 
> Jari, what kind of calculation do you do?

I'll use different approaches for different situations. Starting inject 
with nil or first item will both become handy. Thanks!

The tasks are for analyzing musical data. The current note is most often 
dependent of previous context.


Best regards,

Jari Williamsson