| It might be useful, when collecting a pattern, to have access inside the collect func to both the value coming from the collected stream AND the inval passed in with .next(). Currently only the former is available. Are there any objections to these changes? They would make collect, select, and reject more useful when used inside a Pbind. E.g., Pseries(0, 1, 5).collect({ |x, y| x * y }).asStream.nextN(6, 2); [ 0, 2, 4, 6, 8, nil ] Pseries(0, 1, 5).collect({ |x, y| x * y }).asStream.nextN(6, 3); [ 0, 3, 6, 9, 12, nil ] + Stream { // combination collect { arg argCollectFunc; // modify a stream var nextFunc = { arg inval; var nextval = this.next(inval); if ( nextval.notNil, { argCollectFunc.value(nextval, inval) }) }; var resetFunc = { this.reset }; ^FuncStream.new(nextFunc, resetFunc); } reject { arg function; // reject elements from a stream var nextFunc = { arg inval; var nextval = this.next(inval); while { nextval.notNil and: { function.value(nextval, inval) } }{ nextval = this.next(inval); }; nextval }; var resetFunc = { this.reset }; ^FuncStream.new(nextFunc, resetFunc); } select { arg function; // select elements from a stream var nextFunc = { arg inval; var nextval = this.next(inval); while { nextval.notNil and: { function.value(nextval, inval).not } }{ nextval = this.next(inval); }; nextval }; var resetFunc = { this.reset }; ^FuncStream.new(nextFunc, resetFunc); } } Thanks, hjh : H. James Harkins : jamshark70@xxxxxxxxxxxxxxxxx : http://www.dewdrop-world.net .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman |