Polynomial derivative: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Raku}}: Add a Raku example) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: trap an edge condition for exponents > 9 (doesn't matter here)) |
||
Line 135: | Line 135: | ||
sub pretty (@poly) { |
sub pretty (@poly) { |
||
my $p = join '+', (^@poly).reverse.map: { @poly[$_] ~ "x{.&super}" } |
my $p = join '+', (^@poly).reverse.map: { @poly[$_] ~ "x{.&super}" } |
||
$p.=subst(/'+-'/, ' |
$p.=subst(/['+'|'-']'0x'<[⁰¹²³⁴⁵⁶⁷⁸⁹]>*/, '', :g).subst(/'x¹'<?before <-[⁰¹²³⁴⁵⁶⁷⁸⁹]>>/, 'x')\ |
||
.subst(/ |
.subst(/'x⁰'$/, '').subst(/'+-'/, '-', :g).subst(/(['+'|'-'|^])'1x'/, {"$0x"}, :g) || 0 |
||
} |
} |
||