diff
diff(arr)
diff(arr, dim)
Create a new matrix or array with the difference of the passed matrix or array.
Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference
If no dimension parameter is passed it is assumed as dimension 0
Dimension is zero-based in javascript and one-based in the parser
Arrays must be 'rectangular' meaning arrays like [1, 2]
If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays
Try it yourself:
| @1 |
A = [1, 2, 4, 7, 0]
|
|
| @2 |
diff(A)
|
|
| @3 |
diff(A, 1)
|
|
| @4 |
B = [[1, 2], [3, 4]]
|
|
| @5 |
diff(B)
|
|
| @6 |
diff(B, 1)
|
|
| @7 |
diff(B, 2)
|
|
| @8 |
diff(B, bignumber(2))
|
|
| @9 |
diff([[1, 2], matrix([3, 4])], 2)
|
See also:
All functions