Indexing Arrays - IBM 5110 User Manual

Apl
Table of Contents

Advertisement

22
INDEXING ARRAYS
You may not want to refer to the vvhole array but just to certain
elements. Referring to only certain elements is called indexing. Index
numbers must be integers; they are enclosed in brackets and written
after the name of the variable to which they apply. Assume that A is
assigned a vector as follows: A
+-
11 12 13 14 15 16 17. The result of
entering A is the whole vector, and the result of entering A[2] is 12
(assuming the index origin is 1).
H43re are some more examples of indexing:
A~11
12 13 14 15 16 17
A[~~]
A[~:)
3 7 1]
:I.~3
:1.3
17
1:1.
B~<5 1 1+ 6
Blank Character
ACB]
I
13111.1-1·
:1.6
~
B~IABCDEFGHIJKLMNOPQRSTUVWXYZ
I
BC4 1 14 27 1 :1.4 4 27 3 12 1 9 18]
[lp,N AND
CLA I
r~
C~22
9 :1.8 7 9 14 9 1
BCe]
VIRGINIA
If you use an index that refers to an element that does not exist in the
array, the instruction cannot be executed and INDEX ERROR results:
(~
11
12 13 14 15 :1.6
17
A[B]
INDEX
Er~RDI~
Ar8]
f\.
You cannot index or do anything else with an array until after the array
has been specified. For example, suppose that no value has been
assigned to the name Z; then an attempt to store values in certain
elements within Z would result in an error, because those elements do
not exist:
Z[:.3
1+]~"18
1+6
V(:,LUE E
I~ I~O I~
Z I::
:3
!.t.::I
~..
1. B
LI·
6

Advertisement

Table of Contents
loading

Table of Contents