Display a linear combination: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) m (→{{header|11l}}) |
Alextretyak (talk | contribs) m (→{{header|11l}}) |
||
Line 39: | Line 39: | ||
{{trans|Python}} |
{{trans|Python}} |
||
<lang 11l>F linear(x) |
<lang 11l>F linear(x) |
||
V a = enumerate(x).filter2((i, v) -> v != 0). |
V a = enumerate(x).filter2((i, v) -> v != 0).map2((i, v) -> ‘#.e(#.)’.format(I v == -1 {‘-’} E I v == 1 {‘’} E String(v)‘*’, i + 1)) |
||
R (I !a.empty {a} E [String(‘0’)]).join(‘ + ’).replace(‘ + -’, ‘ - ’) |
R (I !a.empty {a} E [String(‘0’)]).join(‘ + ’).replace(‘ + -’, ‘ - ’) |
||