IMO something like Pattern.rest or Pattern.asRest should exist, but there is no consensus on that. You could also take James’ suggestion Prest from there.
IMO something like Pattern.rest or Pattern.asRest should exist, but there is no consensus on that. You could also take James’ suggestion Prest from there.
chuckle I just reread that thread… I don’t have a lot to add to it, and tbh, my opinion hasn’t changed very much.
In pattern-land, the baseline way to modify patterns’ results is a filter pattern: Pfin, Pcollect etc.
EDIT deleted one point because it wasn’t true.
I’d also argue that reading the code out loud doesn’t work very well for a rest method. pattern.collect(func) reads as “I have these values, and I want this operation to be done for them.” pattern.rest reads as “I have these values, and… oh, by the way, I want them to be rests.” The latter strikes me as awkward, where the former does not.
Last, I now think Prest should have a count argument (like Pfin) instead of a probability, default = 1. It seems to me that the typical case is to interlace a single rest in the middle of some other sequence. (Unless you’re John Cage, you never want an infinite stream of rests.) Tendency masking should be done by another class.