IBM 5110 User Manual page 29

Apl
Table of Contents

Advertisement

24
Similarly, to refer to the elements in column 4, rows 1, 2, and 1, you
enter:
M[l2
:1.;'·1,]
L~
B
' +
You can use the same procedure to select a matrix within a matrix. If
you want the matrix of those elements in rows 2 and 3 and columns 1,
2, and 1 of M, you enter:
M[2 :5 ;
:1.
2 :1.::1
!5
(.)
~:.:j
? 10
':t
If you do not specify the index number for one or more of the
coordinates of the array that you are indexing, APL assumes that you
want the entire coordinate(s). For instance, to get all of row 2, you
enter:
M[2;]
~.:j
b 'l 8
Or to get all of columns 4 and 1, you enter:
t1 I:: ; J.t.
1.]
q.
1
B
I::'
d
12
9
Note: You still have to enter the semicolon to make clear which
coordinate is which. The number of semicolons required is the rank of
the array minus one. If the correct number of semicolons is not
specified, RANK ERROR results:
t1
~
..
~'5
' + (.) ' .
:I.
2
1~)t1
1'1[6]~"~~
I~ANK
E
I~ I~() I~
M[6]~"9
You can change elements within an array by assigning new values for
the indexed elements. (The rest of the array remains unchanged.)
A~3
3pl 2 3 4 5 6 7 8 9
i~
:1.
")
.......
"7.
,,)
' +
I::'
... J
6
7
B 9
P.[2;
")
~5::1 ~
.. :I. ()
20
An
A
:I.
2
"l'
'.:)
1.1·
10 20
"{
8
9

Advertisement

Table of Contents
loading

Table of Contents