One-argument form See also two-argument form Pick
Disclose will produce an array made up of the items in its right argument. If its argument is a scalar, then the result is the array that is within that scalar, and, in this form, disclose will reverse the effect of enclose. However, if the argument to disclose is a nested vector, the result will be a matrix.
TABLE←2 3⍴⍳6 ⍴⊂TABLE (Result of enclose is a scalar) (Shape of a scalar is an empty vector) ⍴⊃⊂TABLE (Disclose reverses the enclosure) 2 3
The shape of the result of disclose is a combination of the shape of the right argument followed by the shape of the items in the right argument.
⊃(1 2 3) (4 5 6) (Shape of argument is 2, and of each item 1 2 3 within the argument is 3) 4 5 6 ⍴⊃(1 2 3) (4 5 6) (Shape of result is 2 3) 2 3
In general, each item in the argument of disclose must be of the same rank, or be a scalar. If some of the items are scalar or have different shapes, they will be padded to a shape that matches the greatest length along each axis of all of the items in the argument. The prototype of each item in the right argument will be used as the fill item.
⊃(1 2) (3 4 5) (First element length 2, second length 3) 1 2 0 (First element padded to length 3) 3 4 5 ⊃(1 2 3) ('AB') (First element length 3, second length 2) 1 2 3 A B (Second element padded to length 3)
This can be a simple way to make a matrix from a series of different length vectors
(but see also
⊃'JOE' 'JAMES' 'JEREMY' JOE JAMES JEREMY
Disclose with axis
When used with an axis specification, disclose will combine the shape of the right argument and the shape of the items within the right argument according to the axis specification. The overall shape of the result is formed from the combination of the shapes as before, but the axis specification will indicate which axis or axes in the result will be formed from the shape of the items within the right argument.
NUMS←(1 2 3) (4 5 6) (7 8 9) ⊃NUMS (Elements of the vectors within the right 1 4 7 argument form rows in the result 2 5 8 ith element becomes ith row) 3 6 9 ⊃NUMS (ith element becomes ith column) 1 2 3 4 5 6 7 8 9
The same rules will apply for higher dimensional arrays. Thus when forming a rank 3 array from a vector of matrices:
DATA←(2 3⍴⍳6) (2 3⍴'ABCDEF') DATA (Length 2 vector of shape 2 3 matrices) 1 2 3 ABC 4 5 6 DEF ⊃[1 2]DATA (First and second axes of result made up 1A from shape of elements of right argument. 2B ith plane, jth row from ith row jth col 3C of each element of right argument) 4D 5E 6F ⊃[1 3]DATA (First and third axes of result from shape 1 2 3 of elements of right argument. A B C ith plane, jth column from ith row jth col of each element of right argument) 4 5 6 D E F ⊃[2 3]DATA (Second and third axes of result from shape 1 2 3 of elements of right argument. 4 5 6 ith row jth column from ith row jth column of each element of right argument) A B C D E F
Disclose with axis can also be used to carry out a rearrangement of its arguments
⊃[3 2]DATA (Second and third axes of result made up 1 4 from shape of elements of right argument. 2 5 jth row ith column from ith row jth 3 6 column of each element of right argument) A D B E C F
Copyright © 1996-2010 MicroAPL Ltd