Display a linear combination: Difference between revisions
Content deleted Content added
Alextretyak (talk | contribs) |
Alextretyak (talk | contribs) |
||
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(‘ + -’, ‘ - ’) |
||