Skip to content
isawdrones edited this page Apr 2, 2011 · 1 revision

+x is the transpose of a list, the rows and columns of a list are exchanged.
The concept extends to higher dimensional lists with the two leading dimensions’ elements being exchanged.
The resulting shape of a list after a flip is: {(|2#x),2_ x}^:

  es:{x#!*/x}           / enumerate lists by shape
  fs:{(|2#x),2_ x}^:    / flipped shape

  a:es 3 3
(0 1 2
 3 4 5
 6 7 8)

  +a
(0 3 6
 1 4 7
 2 5 8)

  +("abc";"def")
("ad"
 "be"
 "cf")

  b:es 2 3 2     / shape is 2 3 2
((0 1
  2 3
  4 5)
 (6 7
  8 9
  10 11))

  +b
((0 1
  6 7)
 (2 3
  8 9)
 (4 5
  10 11))

  ^+b
3 2 2
  (fs b) ~ ^+b
1
Clone this wiki locally