⍴ Reshape r←x⍴y
x must be a vector of integers. Either all elements are natural, or exactly one of them is ¯1 and all others are natural.
r is the elements of y reshaped to the shape defined by x:
- if
×/xis equal to×/⍴y, the elements ofyare simply reordered to fit the new shapex - if
×/xis positive and less than×/⍴y, elements ofyare dropped from the end to fit the new shape - if
×/xis greater than×/⍴y, elements ofyare repeated cyclically to fit the new shape - if
¯1∊x, the product of all elements ofxthat are not¯1must be a divisor of the amount of elements ofy, and the resulting shape is obtained by substituting(×/⍴y)÷×/x⌿⍨¯1≠xfor the¯1inx.
Fails if y is empty and x describes a nonempty shape.