Finding The Shape And Rank Of An Array - IBM 5110 User Manual

Apl
Table of Contents

Advertisement

20
Finding the Shape and Rank of An Array
Once you have generated an array, you can find its shape (number of
elements in each coordinate) by specifying p (shape function) with
only a right argument, which is the name of the array. If A is a vector
with six elements and you enter p A, the result is one number because
A is a one-dimensional array. The number is 6, the length (number of
elements) of A. The result of the shape function is always a vector:
6
A~111
222 333 444 555 666
~)A
The shape of a matrix or N-rank array is found the same way:
M~"2
M
: 1 . 2
:3
l~
5
6
~)M
2
~5
1~~"2
3
4p1
2 3 4 5 6 7 8
R
1
2
3 4·
~5
6
"' 1 B
1 2 3 4,
1::-
",
6
"7 B
1
2
~'5
~5
6 '7 B
~) I~
2
~3
In some cases, it might be necessary to know just the rank, the
number or coordinates (or indices) of an array. To find the rank, enter
p p (shape of the shape) and a right argument, which is the name of
the array:
6
:L
2
~3
2
I')
.:
..
3
~~
A~lll
222 333 444 555 666
B~2
3p1 2 3 4 5 6
C~2
3
4p1
2 3 4 5 6
'7
pA
(.>(.)A
,~B
p~)B
(.)C
ppC

Advertisement

Table of Contents
loading

Table of Contents