(
('
c
One
of
the
simplest kinds
of
arrays,
the
vector, has only
one
dimension; it
can
be
thought
of
as a collection
of
elements
arranged along a horizontal line.
The
num-
bers
that
indicate
the
positions
of
elements
in
an
array are called indices. An
element
can be selected from a vector
by
a single index, since a
vector
has
only
one
dimen-
sion.
The
following
example
shows assigning a numeric
and
a
character
vector
to
two
variable names,
Nand
C;
the
names are
then
entered
to
display
the
values
they
re-
present:
N~5
6.2
-3
888
95.12
N
~;
6.2
-::5
aB8
(y~;.
:1.2
C~"
·
ABCDEFG'
c
ABCDEFG
Generating Arrays
The
most
common
way
to
generate an array
is
to
specify
the
following:
the
shape
the
array
is
to
have-that
is,
the
length
of
each
coordinate;
the
values
of
the
ele-
ments
of
the
new array.
The
APL
function
that
forms
an
array
is
the
reshape
function.
The
symbol for
the
reshape
function
is
p.
The
format
of
the
function
used
to
generate a n array
is
X p
Y,
where X
is
the
shape
of
the
array and Y represents
the
values for
the
elements
of
the
array.
For
the
left
argument
(X),
you
enter
a
number
for
each
coordinate
to
be generated;
this
number
indicates
the
length
of
the
coordinate.
Each
number
in
the
left
argument
must
be
separated
by
at
least
one
blank.
The
values
of
the
elements
of
the
new array are
whatever
you
enter
as
the
right
argument
(Y).
The
instruction 7 p A means
that
the
array
to
be
generated has
'one dimension (is a vector) seven
elements
in length,
and
that
seven values are
to
be supplied
from
whatever
values are
found
stored
under
the
name
A. It
does
not
matter
how
many
elements
A has, as long as it has at least
one
element.
If A has
fewer
than
seven elements, its
elements
are repeated as
often
as needed
to
provide
seven entries in
the
new vector. If A has
more
than
seven elements,
the
first seven
are used.
The
following examples
show
generation
of
some
vectors:
7(.>:1.
2 ]
:1.2:.3123:1.
2p12~5
123
:1.23
5(.)1
.
~5
1.3 1.3 1.3 1.3
1.3
An array with
two
coordinates
(rows
and
columns)
is
called a
matrix.
Columns
Rows
33