Pexp
JMcC: There is already an exponential pattern called Pgeom.
//is this an exponential decay pattern? maybe yes...
//by Julian Rohrhuber
Pexp : Pattern { // exponential series
var <>start=0.5, <>exp=2.0, <>length=inf;
*new { arg start = 1.0, exp = -0.5, length=inf;
^super.newCopyArgs(start, exp, length)
}
asStream {
var cur, counter = 0;
cur = start;
^FuncStream.new({
var outval;
if (counter >= length, {
nil
},{
outval = cur;
cur = cur * exp;
counter = counter + 1;
outval
});
},{
cur = start;
counter = 0;
});
}
}
Links to this Page
- enter. last edited on 29 January 2003 at 10:46 pm by 203.14.169.19
- Test Patches last edited on 20 November 2002 at 8:25 pm by cg-228.noc.valueweb.com