Pselect: table of contents
Filter:
Classes | Streams-Patterns-Events > Patterns > Filter

Pselect : FuncFilterPattern : FilterPattern : Pattern : AbstractFunction : Object

Filters values returned by a source pattern.

Description

This pattern will filter the source pattern using the supplied function func.

Values from the source pattern will be passed to func. Pselect will only return that value if the func returns true.

This is the pattern library's equivalent of select.

Class Methods

Pselect.new(func, pattern)

From superclass: FuncFilterPattern

Arguments:

func

A Function that takes one parameter (the next value from pattern) and returns a boolean.

pattern

The source Pattern.

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

.asStream

.embedInStream(inval)

Examples

(
var a, b;
a = Pselect({ arg item; item != 2 }, Pseq(#[1, 2, 3],inf));
x = a.asStream;
9.do({ x.next.postln; });
)

The message select returns a Pselect when passed to a pattern.

(
var a, b;
a = Pseq(#[1, 2, 3],inf).select({ arg item; item != 2 });
a.postln;
x = a.asStream;
9.do({ x.next.postln; });
)