⊃ — Mix / Pick
Function. Keys: Alt-x. Hanzi: 选/合 (選/合). Ranks: 0 monadic, 1 ∞ dyadic
⊃Y assembles items into rectangular cells, padding to a common shape with fill.
⊃1 2 3 ⍝ 1 2 3
⊃[[1 2] [3 4 5]] ⍝ [1 2 0⋄3 4 5]The result keeps the keys and axis names that the cells agree on. A cell without keys or a name agrees with any, as in arithmetic. An axis that needs padding loses its keys.
⊃[10 20;["a":1 "b":2]] ⍝ ["a":10 "b":20⋄"a":1 "b":2]P⊃Y follows the path P into Y, one level for each item of P. A level is a position or key, or a vector of them with one for each leading axis it selects. With fewer positions than axes, a level selects the cell made of the remaining axes. With one for every axis, it selects that item. The next level enters a nested item. An empty path returns Y. 1 1⊃m takes row 1 of m, then item 1 of that row.
1⊃2 3⍴⍳6ₓ ⍝ [3 4 5]ₓ
[[1 1]]⊃2 3⍴⍳6ₓ ⍝ 4ₓ
1 1⊃2 3⍴⍳6ₓ ⍝ 4ₓ
1 0⊃[[1 2] [3 4]] ⍝ 3
⍬⊃1 2 ⍝ 1 2A level can use strings on keyed axes. A path enters nested records as dot access does: ["a" "b"]⊃T is T.a.b.
T←["price":1 2 3;"qty":4 5 6]
"qty"⊃T ⍝ 4 5 6
"qty" 1⊃T ⍝ 5A level selects one item or cell. To read several items, use Dot indexing: x.[[0 2] [1 3]] pairs two arrays of positions.
With axes, ⊃⍠A Y places the cell axes of Mix among the frame axes. See Axis. On Pick, negative positions count from the end. A position outside its axis or not a whole number gives fill, as Indexing describes. So does position 0 or ¯1 on an empty axis, as it does for First. ⍠ can choose the fill for Mix, and for the last level of Pick’s path.
Inverse
⊃⁻Y splits Y into vectors along its last axis.
⊃⁻[1 2⋄3 4] ⍝ [1 2;3 4]Errors
RANK: Mix axes not a unit or vector, a path not a unit or vector, a level with more positions than its array has axesLENGTH: Mix axis count not the cell rankINDEX: a Mix axis outside the resultDOMAIN: repeated or fractional Mix axes, a level that holds an array of positions
A missing key gives the fill too.