View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

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