Formal power series: Difference between revisions

Content added Content deleted
Line 2,251: Line 2,251:


=={{header|zkl}}==
=={{header|zkl}}==
zkl iterators (aka Walkers) are more versatile than the run-of-the-mill iterator and can be used to represent infinite sequences (eg a finite set can be padded forever or cycled over), which works well here. The Walker tweak method is used to modify iterator behavior (ie how to filter the sequence, what to do if the sequence ends, etc). The Haskell like zipWith Walker method knows how to deal with infinite sequences.
<lang zkl>class IPS{
<lang zkl>class IPS{
var [protected] w; // the coefficients of the infinite series
var [protected] w; // the coefficients of the infinite series
Line 2,266: Line 2,267:
self
self
}
}
fcn __opSub(ipf){ w=w.zipWith('-,ipf.w); self } // IPS - IPS
fcn __opSub(ipf){ w=w.zipWith('-,ipf.w); self } // IPS - IPSHaskell
fcn __opMul(ipf){ } // stub
fcn __opMul(ipf){ } // stub
fcn __opDiv(x){ w.next().toFloat()/x } // *IPS/x, for integtate()
fcn __opDiv(x){ w.next().toFloat()/x } // *IPS/x, for integtate()