Shape Of | $ _ 1 _ | Shape |
$ y yields the shape of y as defined
in Section II A. For example,
the shape of a 2-by-3 matrix is 2 3, and the shape of
the scalar 3 is an empty list
(whose shape is 0). The rank of an argument y is #@$ y . For example: rank=: #@$ (rank 3) , (rank ,3) 0 1 (rank 3 4),(rank i. 2 3 4) 1 3 |
The shape of x$y is x,siy where siy is
the shape of an item of y; x$y gives a length error
if y is empty and x,siy does not contain a zero.
For example:y=: 3 4$'abcdefghijkl' y ; 2 2$ y +----+----+ |abcd|abcd| |efgh|efgh| |ijkl| | | |ijkl| | |abcd| +----+----+ This example shows how the result is formed from the items of y , the last 1-cell (abcd) showing that the selection is cyclic. The fit conjunction ($!.f) provides fill specified by the atom f , or the normal fill defined under Take ({.) if f is an empty vector. |
2 3 $ ,y abc defThe fit conjunction is often useful for appending zeros or spaces. For example:
8 $!.0 (2 3 4) 2 3 4 0 0 0 0 0 ]z=: 8$!.'*' 'abc' abc***** |. z *****cba 2 5$!.a: ;: 'zero one two three four five six' +----+---+---+-----+----+ |zero|one|two|three|four| +----+---+---+-----+----+ |five|six| | | | +----+---+---+-----+----+