Generating Arrays - IBM 5110 User Manual

Apl
Table of Contents

Advertisement

Generating Arrays
The most common way to generate an array is to specify the shape
the array is to have (that is, the length of each coordinate) and the
values of the elements 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 an array is Xp 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 7pA 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:
"('
I~):I.
2 :,3
:1.2:'512:31.
2(.):1.2:'5
: 1 .
:~~:3
:L 2 3
~5(.):I.
.3
1.3 :1..3 1.3 :1..3 1,3
APL Language Elements
17

Advertisement

Table of Contents
loading

Table of Contents