[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] RFC: Pseq change



I like this for Pseq. I'm not sure how it would work for Prand and its siblings, since they don't iterate over the entire collection. How would you determine when to get the next list?

Very likely the intended use of reverse is where you have a number of short, finite Pbinds being chosen in a higher level pattern (Pseq or Prand, e.g.). But it does seem an odd way to go about it, and one that I don't recall having occasion to use.

hjh


On Dec 3, 2007, at 8:04 AM, ronald kuivila wrote:

Hi all,

I would like to propose that some list patterns (Pseq, Prand, Pwrand) be able to take a pattern in their list argument.
This makes it possible to use Pstep or Pseg to change the collection of values used over time.  

In the case of Pseq, the pattern would get an array from the list stream, iterate and then get another.  This does not change
existing uses at all, but it does add a 'next'. Any objections?

Also, I notice that Pseq has this support for a 'reverse' key.  This seems pretty hackish as it would apply to all
Pseqs in the event stream.  Am I missing something? I wonder if this switch could or should be deleted:

Pseq : ListPattern {
var <>offset;
*new { arg list, repeats=1, offset=0;
^super.new(list, repeats).offset_(offset)
}
embedInStream {  arg inval;
var item, offsetValue,listStream, listVal;
offsetValue = offset.value;
listStream = list.asStream;
if (inval.eventAt('reverse') == true, {
repeats.value.do({ arg j;
listVal = listStream.next(inval);
if (listVal.isNil) {^inval };
listVal.size.reverseDo({ arg i;
item = listVal.wrapAt(i + offsetValue);
inval = item.embedInStream(inval);
});
});
},{
repeats.value.do({ arg j;
listVal = listStream.next(inval);
if (listVal.isNil) {^inval };
listVal.size.do({ arg i;
item = listVal.wrapAt(i + offsetValue);
inval = item.embedInStream(inval);
});
});
});
^inval;
}
storeArgs { ^[ list, repeats, offset ] }
}

RJK
_______________________________________________
Sc-devel mailing list


: 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