Display a linear combination: Difference between revisions
→{{header|Perl 6}}: more compact code. Arguably more obscure, but still probably OK
m (→{{header|Perl 6}}: forgot to remove a line) |
(→{{header|Perl 6}}: more compact code. Arguably more obscure, but still probably OK) |
||
Line 27:
=={{header|Perl 6}}==
<lang perl6>sub linear-combination(@coeff) {
join(
@terms.=grep(+*.key);▼
map { .key ~ '*' ~ .value },
(@coeff Z=> map { "e($_)" }, 1 .. *)
)\
▲ my $result = join '+',
.subst(/<|w>1\*/, '', :g);
}
|