reshape
Reshape
x#y
The reshape primitive takes the elements of an array y
, and fits them in a rectangular nested array shape given by x
.
The array elements are repeated to fit the shape given in x
, if the product of x is greater than the length of y.
3 3#3 (3 3 3 3 3 3 3 3 3) 2 4 1#("ab";56;`sdas) ((,"ab";,56;,`sdas;,"ab") (,56;,`sdas;,"ab";,56))
In K3, -1 can be given as a dimension to get a rectangular array. Note that if the length of the array isn't evenly divisible by the dimension, it will throw an error.
Effectively, it means "maximize this dimension with respect to the other dimension and the size of the array."
K6 and its successors allow 0N
as the first or last dimension.
This can result in non-rectangular arrays, since it splits the array y
to fit the constraints in x
.
3 0N#1 2 3 (,1 ,2 ,3)