Display a linear combination: Difference between revisions
→{{header|Perl 6}}: style
(→{{header|Perl 6}}: Added zkl) |
(→{{header|Perl 6}}: style) |
||
Line 27:
=={{header|Perl 6}}==
<lang perl6>sub linear-combination(@coeff) {
.map({ .key
.join('+')\
▲ .subst('+-', '-', :g)\
▲ .subst(/<|w>1\*/, '', :g);
}
say linear-combination(
[1, 2, 3],
[0, 1, 2, 3],
Line 48 ⟶ 46:
[-1, -1, -1],
[-1, -2, 0, -3],
[
;</lang>
{{out}}
|