Anonymous user
Display a linear combination: Difference between revisions
m
→{{header|REXX}}: changed whitespace, elided a blank line, added/changed comments, split a THEN/ELSE.
m (→{{header|REXX}}: changed whitespace, elided a blank line, added/changed comments, split a THEN/ELSE.) |
|||
Line 1,244:
=={{header|REXX}}==
<lang rexx>/*REXX program displays a finite liner combination in an infinite vector basis.
@.= .; @.1 = ' 1, 2, 3
@.2 = ' 0, 1, 2, 3 '
@.3 = ' 1, 0, 3, 4 '
@.4 = ' 1, 2, 0
@.5 = ' 0, 0, 0
@.6 = 0
@.7 = ' 1, 1, 1
@.8 = ' -1, -1, -1 '
@.9 = ' -1, -2, 0, -3 ' /*
@.10 = -1
do j=1 while @.j\==.; n= 0
y= space( translate(@.j, ,',') ) /*elide commas and superfluous blanks. */
$= /*nullify output (liner combination).*/
do k=1 for words(y);
if #=0 then iterate;
if #<0 then s= '
if a\==1 then s= s || a'*' /*if multiplier is unity, then ignore #*/
end /*k*/▼
$= $ s'e('k")" /*construct a liner combination element*/
▲ end /*k*/
$= strip( strip($), 'L', "+") /*strip leading plus sign (1st element)*/
if $=='' then $= 0 /*handle special case of no elements. */
|