View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

Pfunc/Pfuncn/Prout

Pfunc returns a value obtained from the evaluated function each
call. On reset, the reset function is called.

a = Pfunc({ rrand(8, 10) });
b = a.asStream;
20.do({ b.next.postln });

Pfuncn does that only a certain number of times:
a = Pfuncn({ rrand(8, 10) },4);
c = Pfuncn({ rrand(1.0, 2.0) },4);
b = Pseq([a, c], inf).asStream;
20.do({ b.next.postln });

Prout creates a Routine instead, that will yield values without
restarting and thus no reassignment of any variables:
a = Prout({ 
	4.do({arg i;
		55.yield;
		i.yield;
		Pshuf([1, 2, 3]).embedInStream
	})
});
b = a.asStream;
20.do({ b.next.postln });




Links to this Page