Display a linear combination: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
Line 562:
[-1, -2, 0, -3] -> -e(1) - 2*e(2) - 3*e(4)
[-1] -> -e(1)</pre>
 
=={{header|EasyLang}}==
{{trans|Ring}}
<syntaxhighlight>
scalars[][] = [ [ 1 2 3 ] [ 0 1 2 3 ] [ 1 0 3 4 ] [ 1 2 0 ] [ 0 0 0 ] [ 0 ] [ 1 1 1 ] [ -1 -1 -1 ] [ -1 -2 0 -3 ] [ -1 ] ]
for n = 1 to len scalars[][]
str$ = ""
for m = 1 to len scalars[n][]
scalar = scalars[n][m]
if scalar <> 0
if scalar = 1
str$ &= "+e" & m
elif scalar = -1
str$ &= "-e" & m
else
if scalar > 0
str$ &= strchar 43 & scalar & "*e" & m
else
str$ = scalar & "*e" & m
.
.
.
.
if str$ = ""
str$ = 0
.
if substr str$ 1 1 = "+"
str$ = substr str$ 2 (len str$ - 1)
.
print str$
.
</syntaxhighlight>
{{out}}
<pre>
e1+2*e2+3*e3
e2+2*e3+3*e4
e1+3*e3+4*e4
e1+2*e2
0
0
e1+e2+e3
-e1-e2-e3
-3*e4
-e1
</pre>
 
=={{header|EchoLisp}}==
1,983

edits