Posted at

AppleScriptの2次元リストを行列として、転置行列を取得するAppleScriptハンドラ

More than 1 year has passed since last update.


  • 引数matrixが正しい行列かどうかはチェックしない


transposeMatrix.scpt

return my transposeMatrix({{"A1", "A2", "A3"}, {"B1", "B2", "B3"}})

--> {{"A1", "B1"}, {"A2", "B2"}, {"A3", "B3"}}

on transposeMatrix(matrix as list)
set transposedMatrix to {}
repeat count (item 1 of matrix) times
set end of transposedMatrix to {}
end repeat
repeat with row in matrix
repeat with i from 1 to count row
set end of item i of transposedMatrix to item i of row
end repeat
end repeat
return transposedMatrix
end transposeMatrix



更新履歴


  • 2017-11-15: 新規作成