Identity matrix: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Added Arturo implementation) |
|||
Line 540: | Line 540: | ||
{{output}} |
{{output}} |
||
<lang applescript>{{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}</lang> |
<lang applescript>{{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}</lang> |
||
=={{header|Arturo}}== |
|||
<lang rebol>identityM: function [n][ |
|||
result: array.of: @[n n] 0 |
|||
loop 0..dec n 'i -> result\[i]\[i]: 1 |
|||
return result |
|||
] |
|||
loop 4..6 'sz [ |
|||
print sz |
|||
loop identityM sz => print |
|||
print "" |
|||
]</lang> |
|||
{{out}} |
|||
<pre>4 |
|||
1 0 0 0 |
|||
0 1 0 0 |
|||
0 0 1 0 |
|||
0 0 0 1 |
|||
5 |
|||
1 0 0 0 0 |
|||
0 1 0 0 0 |
|||
0 0 1 0 0 |
|||
0 0 0 1 0 |
|||
0 0 0 0 1 |
|||
6 |
|||
1 0 0 0 0 0 |
|||
0 1 0 0 0 0 |
|||
0 0 1 0 0 0 |
|||
0 0 0 1 0 0 |
|||
0 0 0 0 1 0 |
|||
0 0 0 0 0 1</pre> |
|||
=={{header|BASIC}}== |
=={{header|BASIC}}== |