Jump to content

Matrix with two diagonals: Difference between revisions

(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 2,509:
<br>
[http://keptarhely.eu/view.php?file=20220217v00xdle18.jpeg Special identity matrix with two diagonals]
 
=={{header|RPL}}==
Approach here is to fill the second diagonal of an identity matrix generated by IDN instruction, thanks to a classical FOR.. NEXT loop.
{{works with|Halcyon Calc|4.2.7}}
≪ IDN LAST
1 OVER FOR line
line OVER 2 →LIST ROT SWAP 1 PUT
SWAP 1 -
NEXT
DROP
‘XDIAG’ STO
 
5 XDIAG
6 XDIAG
{{out}}
<pre>
2: [[ 1 0 0 0 1 ]
[ 0 1 0 1 0 ]
[ 0 0 1 0 0 ]
[ 0 1 0 1 0 ]
[ 1 0 0 0 1 ]]
1: [[ 1 0 0 0 0 1 ]
[ 0 1 0 0 1 0 ]
[ 0 0 1 1 0 0 ]
[ 0 0 1 1 0 0 ]
[ 0 1 0 0 1 0 ]
[ 1 0 0 0 0 1 ]]
</pre>
 
=={{header|Sidef}}==
1,150

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.