Different Way Forward Given a list of integers produce a Forward Difference at a specified order/depth.

For the list of integers:

(10, 18, -12, 4, 8, -3, -5, 67, 9, 14)


The Forward Differences at the various orders/depths are:

0   10,   18,  -12,    4,    8,   -3,   -5,  67,  9,  14
1      8,  -30,   16,    4,  -11,   -2,   72, -58,  5
2       -38,   46,  -12,  -15,    9,   74, -130, 63
3           84,  -58,   -3,   24,   65, -204, 193
4            -142,   55,   27,   41, -269, 397
5               197,  -28,   14, -310, 666
6                 -225,   42, -324, 976
7                    267, -366, 1300
8                      -633, 1666
9                         2299


So with the input of

4, (10, 18, -12, 4, 8, -3, -5, 67, 9, 14)


You would return the list

(-142,   55,   27,   41, -269, 397)


Input

The input can be via STDIN or function parameters.

An integer specifying the depth to return.  This will be 0 to the length of the list minus 1

A list of integers to calculate the forward difference for

Output

The output can be via STDOUT or returned by the function.

The forward differences for the specified depth as a list of integers

Rules

Built in and 3rd Party functions that do this directly are not allowed.

Standard loophole restrictions apply.

Shortest code wins
J, 15 9 7 bytes

Very easy. Takes depth and list as left and right arguments.

-~/\~&amp;2


As an explicit definition without all the adverbial trickery, this reduces to

4 : '(2 -~/\ ])^:x y'



-~/\~&amp;2 y – The forwards difference of y.
x -~/\~&amp;2 y – The x-th forwards difference of y.


If I were to make a serious (i.&thinsp;e. non-golfed) definition of this function, I would probably do something like this:

(}. - }:) : ($:@[&amp;0)


The monadic case computes the forward difference whereas the dyadic case computes the x-th forward difference.

Even simpler, but not exactly equal:

+/\inv


+/\ yields a vector of the sums of the prefixes of the argument. inv (defined as ^:_1) is a conjunction that inverses a verb. This works wherever J knows how to inverse a verb and for the case of +/\, J knows how to.