⍴
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
×/x
is equal to×/⍴y
, the elements ofy
are simply reordered to fit the new shapex
- if
×/x
is positive and less than×/⍴y
, elements ofy
are dropped from the end to fit the new shape - if
×/x
is greater than×/⍴y
, elements ofy
are repeated cyclically to fit the new shape - if
¯1∊x
, the product of all elements ofx
that are not¯1
must be a divisor of the amount of elements ofy
, and the resulting shape is obtained by substituting(×/⍴y)÷×/x⌿⍨¯1≠x
for the¯1
inx
.
Fails if y
is empty and x
describes a nonempty shape.