Skip to content

Pattern: PDiff

Outputs the difference between the current and previous values of an input pattern

If the current or next value are None, a value of None will be output. The length of the output pattern is always 1 less than the length of the input.

Example output

>>> a = PSequence([1, 0, 1, 2, 2, 2, 1, 0, 0, 1], repeats=1)
>>> b = PDiff(a)
>>> b.all()
[-1, 1, 1, 0, 0, -1, -1, 0, 1]