Matrix transposition: Difference between revisions
Content added Content deleted
m (→{{header|Ruby}}: add libheader) |
(+ AutoHotkey) |
||
Line 82: | Line 82: | ||
( 1.00, 8.00, 27.00, 64.00,125.00), |
( 1.00, 8.00, 27.00, 64.00,125.00), |
||
( 1.00, 16.00, 81.00,256.00,625.00)); |
( 1.00, 16.00, 81.00,256.00,625.00)); |
||
=={{header|AutoHotkey}}== |
|||
<lang AutoHotkey>a = a |
|||
m = 10 |
|||
n = 10 |
|||
loop, 10 |
|||
{ |
|||
i := A_Index - 1 |
|||
loop, 10 |
|||
{ |
|||
j := A_Index - 1 |
|||
%a%%i%%j% := i - j |
|||
} |
|||
} |
|||
before := matrix_print("a", m, n) |
|||
transpose("a", m, n) |
|||
after := matrix_print("a", m, n) |
|||
msgbox % before . "`ntransposed:`n" . after |
|||
return |
|||
transpose(a, m, n) |
|||
{ |
|||
local i, j, row, matrix |
|||
loop, % m |
|||
{ |
|||
i := A_Index - 1 |
|||
loop, % n |
|||
{ |
|||
j := A_Index - 1 |
|||
temp%i%%j% := %a%%j%%i% |
|||
} |
|||
} |
|||
loop, % m |
|||
{ |
|||
i := A_Index - 1 |
|||
loop, % n |
|||
{ |
|||
j := A_Index - 1 |
|||
%a%%i%%j% := temp%i%%j% |
|||
} |
|||
} |
|||
} |
|||
matrix_print(a, m, n) |
|||
{ |
|||
local i, j, row, matrix |
|||
loop, % m |
|||
{ |
|||
i := A_Index - 1 |
|||
row := "" |
|||
loop, % n |
|||
{ |
|||
j := A_Index - 1 |
|||
row .= %a%%i%%j% . "," |
|||
} |
|||
stringtrimright, row, row, 1 |
|||
matrix .= row . "`n" |
|||
} |
|||
return matrix |
|||
}</lang> |
|||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
{{works with|QuickBasic|4.5}} |
{{works with|QuickBasic|4.5}} |