Transpose: Difference between revisions
Content added Content deleted
m (Lowercase title) |
("Paragraph cleanup") |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{lowercase title}} |
|||
{{primitive|+x}} |
{{primitive|+x}} |
||
[[File:Matrix_transpose.gif|256px|right|thumb|Matrix transposition]] |
[[File:Matrix_transpose.gif|256px|right|thumb|Matrix transposition]] |
||
''' |
'''transpose''', a.k.a. '''flip''', swaps the two leading axes of a 2+ dimensional rectangular array. Dialects differ in their treatment of atoms, lists, and ragged arrays. |
||
+("ab";"cd";"ef") |
+("ab";"cd";"ef") |
||
("ace" |
("ace" |
||
"bdf") |
"bdf") |
||
Atoms in otherwise rectangular arrays are extended to the full length of the corresponding dimension: |
Atoms in otherwise rectangular arrays are extended to the full length of the corresponding dimension: |
||
+(`a`b`c;`d) |
+(`a`b`c;`d) |
||
Line 11: | Line 12: | ||
`b`d |
`b`d |
||
`c`d) |
`c`d) |
||
==Atoms and lists== |
==Atoms and lists== |
||
Transposing a list in oK or ngn/k [[enlist]]s it. Transposing an atom enlists twice<ref>https://github.com/JohnEarnest/ok/issues/77</ref>: |
Transposing a list in oK or ngn/k [[enlist]]s it. Transposing an atom enlists twice<ref>https://github.com/JohnEarnest/ok/issues/77</ref>: |
||
Line 20: | Line 22: | ||
K9 throws a rank error. |
K9 throws a rank error. |
||
==Ragged arrays== |
==Ragged arrays== |
||
oK and ngn/k reshape shorter rows to the length of the longest row: |
oK and ngn/k reshape shorter rows to the length of the longest row: |
||
Line 31: | Line 34: | ||
`b`e |
`b`e |
||
`c`) |
`c`) |
||
[[Category:Verbs]] |
|||
[[Category:Operator verbs]] |
|||
[[Category:Primitives]] |
Latest revision as of 07:59, 9 July 2022
Transpose
+x
transpose, a.k.a. flip, swaps the two leading axes of a 2+ dimensional rectangular array. Dialects differ in their treatment of atoms, lists, and ragged arrays.
+("ab";"cd";"ef") ("ace" "bdf")
Atoms in otherwise rectangular arrays are extended to the full length of the corresponding dimension:
+(`a`b`c;`d) (`a`d `b`d `c`d)
Atoms and lists[edit]
Transposing a list in oK or ngn/k enlists it. Transposing an atom enlists twice[1]:
+,0 ,,0 +0 ,,0
K3, K4, and Kona[2] return the argument as-is.
K9 throws a rank error.
Ragged arrays[edit]
oK and ngn/k reshape shorter rows to the length of the longest row:
+(`a`b`c;`d`e) (`a`d `b`e `c`d)
K9 pads shorter rows with nulls:
+(`a`b`c;`d`e) (`a`d `b`e `c`)