Pseries_back and forth


I would like to know how to use Pseries (or another pattern object) in order to be able to increase the value to its maximum (ie lenght arg) and then automatically proceed to a dicrease, using the same step value.

As an example, with


I would like to go from 1 to 30 and then when it reaches 30, decrease from 30 to 1, and then increase again to 30 and so on… ( infinte continuous process).

Thanks a lot

see if it works for you.

a = Pwalk(
    list:Array.series(30, 1, 1),        // integers, 1-30
    stepPattern:   Pseq([1], inf),    // reverse direction at boundaries
    directionPattern: Pseq([1, -1], inf),
	startPos:0);    // start from 1
x = a.asStream;
){; ", ".post });


It works! thanks a lot.

You can fold the Pseries between 1 and 30

Pbind(\foo, Pseries(1, 1, inf).fold(1, 30).trace).play;