I have a one dimensional array or list containing integers e.g. x = [0, 2, 4, 7, 8, 12, 15, 23, 28, 39]
.
I want to have a function that does the following: Return a list/array storing
x[9]-x[8], x[8]-x[7], x[7]-x[6], ......., x[1]-x[0]
In this example I should get a list/array giving [11, 5, 8, 3, 4, 1, 3, 2, 2].
I need this function to run in a while loop where for each loop the size of the list/array x
grows by 1.
How do I do this in Python or Numpy?
Unlike this other question, this question seeks the difference between elements from the end of a list/array to it's beginning: this question is mathematically different to the other question.