SuperCollider CLASSES

Pcollect

Apply a function to a pattern

Description

Modifies each value by passing it to the function.

Class Methods

*new (func, pattern)

From superclass: FuncFilterPattern

Arguments:

func

A Function. Receives values from pattern.

pattern

A Pattern.

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

-asStream

-embedInStream (inval)

Examples

(
a = Pcollect( { |item| item * 3 }, Pseq( #[ 1, 2, 3 ], inf ) );
x = a.asStream;
9.do( { x.next.postln; } );
)

The message collect returns a Pcollect when passed to a pattern. Note that because the pattern is converted to a Stream (more precisely a FuncStream) the collect function is evaluated for one item each time the message next is passed.

(
a = Pseq( #[ 1, 2, 3 ], inf ).collect( { arg item; item * 3 } );
a.postln;

x = a.asStream;
9.do( { x.next.postln; } );
)