depth

Consecutive differences

Return the differences between consecutive items of a list.

f 3 5 9

should return 2 4.

Hint

There is a built-in that returns differences, but its first item needs handling.

Solution

f:{1_deltas x}

deltas returns the first item unchanged followed by the consecutive differences, so 1_ drops that first item.

Answer

f:{1_deltas x}