Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list
1 3 4 2 8
holds the deltas:
2 1 -2 6
which are then negated, yielding:
-2 -1 2 -6
and recompiled, yielding:
1 -1 -2 0 -6
as the final result.
Input/Output
You will be given a list/array/table/tuple/stack/etc. of signed integers as input through any standard input method.
You must output the modified data once again in any acceptable form, following the above delta inversion method.
You will receive N inputs where 0 < N < 10
where each number falls within the range -1000 < X < 1000
Test Cases
5 6 7 8 -> 5 4 3 2
1 3 4 2 8 -> 1 -1 -2 0 -6
32 18 25 192 199 -> 32 46 39 -128 -135
Notes
- You are not restricted to the delta based method: if you can work out the easier method (which shouldn't be too hard), you're free to use it.
- As stated in above, you will always receive at least 1 input, and no more than 9.
- The first number of the output must always be the first number of the input, if this is not the case, your method is incorrect.
- Only Standard Input Output is accepted
- Standard loopholes apply
- This is code-golf, so the lowest byte-count wins!
- Have fun!
We have a winner.
Dennis's Jelly Answer at a Tiny 3 Bytes has taken home the gold, due to the fact that I am under the impression it cannot be beaten.
I was mildly disappointed I didn't get to see an answer based on the original spec, however, I may later put a bounty on precisely that.