Modifies each value by passing it to the function. This is the pattern library's equivalent of Collection: -collect.
( 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; } ); )