Created
April 8, 2022 19:19
-
-
Save claytonjwong/ed5617c0fcc8ddc6636312b754432cb1 to your computer and use it in GitHub Desktop.
Revisions
-
claytonjwong created this gist
Apr 8, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ *Kotlin* ``` var transpose = { A: Array<IntArray> -> A[0].mapIndexed{ j, _ -> A.mapIndexed{ i, _ -> A[i][j] }.toIntArray() }.toTypedArray() } ``` *Javascript* ``` let transpose = A => A[0].map((_, j) => A.map((_, i) => A[i][j])); ``` *Python3* ``` transpose = lambda A: [[A[i][j] for i in range(len(A))] for j in range(len(A[0]))] ```