ρ — Shape / Reshape
Function. Keys: Alt-r. Hanzi: 形. Ranks: ∞ monadic, 1 ∞ dyadic
ρY gives axis lengths.
ρ2 3ρ0 ⍝ [2 3]ₓThe shape is keyed by the axis names. The length of an unnamed axis has no key. See named axes.
M←["city":2 "month":3]ρι6ₓ
ρM ⍝ ["city":2 "month":3]ₓ
"month"⌷ρM ⍝ 3ₓSρY reshapes, cycling or truncating the items of ,Y. Items of S are nonnegative whole numbers. With empty Y, every item is fill, which ⍠ can set.
2 3ρ1 2 ⍝ [1 2 1◇2 1 2]
3ρ"" ⍝ " "With empty S, the result is a scalar.
⍬ρ1 2 ⍝ ⊂1The keys of S name the result’s axes. An unkeyed item leaves its axis unnamed. When S matches the shape of Y, the result keeps the keys of Y.
ρ["city":2 3]ρι6ₓ ⍝ ["city":2 3]ₓInverse
Sρ⁻Y gives ,Y. The axis lengths of Y must match S.
2 3ρ⁻2 3ρι6ₓ ⍝ [0 1 2 3 4 5]ₓErrors
DOMAIN: an item ofSisn’t a nonnegative whole number, or, forρ⁻, the shape ofYisn’tSLIMIT: the result has too many items