Display a linear combination: Difference between revisions

Add APL
m (moved FreeBASIC to section BASIC)
(Add APL)
Line 191:
</pre>
 
=={{header|APL}}==
{{works with|Dyalog APL}}
<syntaxhighlight lang="apl"> lincomb←{
fmtco←{
mul←(⍵≠1)/(⍕|⍵),'*'
mul,'e(',(⍕⍺),')'
}
 
co←⊃¨fmtco/¨(⍵≠0)/(⍳⍴,⍵),¨|⍵
sgn←'-+'[1+(×⍵)/×⍵]
lc←(('+'=⊃)↓⊢)∊sgn,¨co
0=⍴lc:'0' ⋄ lc
}</syntaxhighlight>
{{out}}
<pre> ↑lincomb¨(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)
e(1)+2*e(2)+3*e(3)
e(2)+2*e(3)+3*e(4)
e(1)+3*e(3)+4*e(4)
e(1)+2*e(2)
0
0
e(1)+e(2)+e(3)
-e(1)+e(2)+e(3)
-e(1)+2*e(2)-3*e(4)
-e(1) </pre>
=={{header|Arturo}}==
 
2,094

edits