Transpose Ragged Array Index   <<   >>


 

I’m trying to transpose a vector of different length vectors, essentially a ragged matrix. The only way I can think of to do it is to introduce a special value which is subsequently removed:

transpose←{
  n←≢¨⍵
  m←⌈/n
  f←⎕NULL
  m←↓⍉⊃⍵,¨(m-n)⍴¨f
  m~¨f
}
   transpose (1 2 3) (4 5) (6 0 7 8 9)
┌─────┬─────┬───┬─┬─┐
│1 4 6│2 5 0│3 7│8│9│
└─────┴─────┴───┴─┴─┘

Dyalog Forum post by paulmansour, 2017-07-24