rsc3/doc-schelp/HelpSource/Classes/Pwhile.schelp

34 lines
755 B
Text

class:: Pwhile
summary:: While a condition holds, repeatedly embed stream
categories:: Streams-Patterns-Events>Patterns>Language Control
description::
Repeatedly strong::embed:: a link::Classes/Stream:: while the result of code::func:: is code::true::.
classmethods::
method:: new
argument:: func
Stream function. In an event stream receives the current link::Classes/Event:: as argument.
argument:: pattern
A link::Classes/Pattern::.
examples::
code::
(
z = true;
a = Pwhile({ z }, Pseq(#[1, 2, 3]));
x = a.asStream;
);
7.do({ x.next.postln; }); // while z == true, the values are embedded
z = false; // set z to false
x.next; // the rest of the stream is still embedded
x.next;
x.next; // but then it is not continued.
x.next;
x.next;
x.next;
::