Skip to content

Pattern: PMap

Apply an arbitrary function to an input pattern.

Will pass any additional arguments, which can also be patterns. Instances of None in the input stream will be passed through to the function as normal.

Example output

>>> PMap(PSeries(), lambda value: value * value).nextn(16)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]
>>> PMap(PSeries(), pow, PSeries()).nextn(16)
[1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 10000000000, ... ]