Formal power series: Difference between revisions
m
→{{header|Perl 6}}: Make coeffs a method in the base class.
m (→{{header|Perl 6}}: Clean up some unneeded semicolons.) |
m (→{{header|Perl 6}}: Make coeffs a method in the base class.) |
||
Line 1,101:
class FPS {
method differentiate { DerFPS.new(:x(self)) }
method integrate { IntFPS.new(:x(self)) }
Line 1,116 ⟶ 1,115:
}
}
class ExplicitFPS is FPS { has @.coeffs }
class SumFPS is FPS {
Line 1,151 ⟶ 1,152:
class IntFPS is FPS {
has FPS $.x
method coeffs { 0, (0..*).map: { $.x.coeffs[$_] / ($_+1) } }
}
Line 1,167 ⟶ 1,168:
# an example for a mixed-type operator:
multi infix:<->(Numeric $x, FPS $y) {
# define sine and cosine in terms of each other
|