can store
items are called variables. Whenever
data
associated with
length with no blanks;
characters can be
names longer
significant
to
data
in
the
5100
that
name. A variable
the
first
any
combination
than
77
characters can
APL.
The +-(assignment arrow)
by
character
LENGTHi··6
WIDTl-lfo8
AREA~LENGTHxWIDTH
To
display
the
value
of
a variable,
enter
assigning it
the
variable name
name
must be
of
alphabetic
be
used,
just
the
to
a variable name. These
is
used, APL supplies
can be
up
to
77
alphabetic
and numeric characters. Variable
but
only
is
used
variable name:
the
to
and
first
assign
the
77
data
stored
characters in
remaining
characters are
to
a variable:
the
6
8
4B
DATA
REPRESENTATION
Numbers
The
character
the
as
than
The
can
LENGTH
WIDTH
I~I~EA
decimal digits 0
- , called
leftmost
zero:
negative sign,
be
used
character
O-lJ.
only
as
through 9 and
the
negative sign,
in
the
-,
is
distinct
part
of
the
the
decimal
is
used
representation
from
- (the symbol used
numeric
constant.
to
of
point
are used
denote
negative numbers. It appears
any
number
to
denote
in
the
whose value
subtraction)
usual way.
is
less
The
and
30
Page 35
Scaled Representation (Scientific Notation)
(".
You can
tiplying it
representation in APL.
by E and
example:
The
the
must
side
represent
Number
66700
.00284
E (E can
digits
be shifted.
of
it.
by
the
appropriate
then
an integer (the scale) representing
be
read times ten to the) in
to
the
right
There
Numeric Value Range
Numeric values in
7.237005577332262E75.
±.
5.397604346934028E -79.
numbers
the
by
The
of
the
can
be
5100 can range
The
stating a value
power
of
ten.
This
form
of
a scaled
Form
Scaled
t
6.67E4
•
2.84E3
E indicate
no
spaces
smallest numeric value
number
Multiplier
Scale
the
middle indicates
the
number
between
from
-7.237005577332262E75
in
some
type
the
the E and
convenient
of
notation
is a number
appropriate
of
places
the
5100 can use
range,
then
is
called scaled
(multiplier) followed
power
of
that
this
is
scaled
that
the
decimal
the
numbers
on
to
is
mul-
10.
point
either
For
form;
c
c:
Numeric Value Precision
Numbers in
digits.
the
5100 are carried internally with a precision
Character Constants
Zero
or
more characters enclosed in single
Appendix
(see
indicate
functions,
the
enclosing
B)
and
that
the. characters
but
represent only themselves. When
quotes
'ABCDEFG'
ABCDEFG
,
:1.23('~BC
123('~BC
M~'THE
M
THE
ANSWER
When a
entered
quote
to
produce
is
required within
the
quotes,
blank characters (spaces),
keyed
do
not
represent numbers, variable names,
are
not
shown:
'
ANSWER
IS:'
IS:
the
character
single
quote
in
the
character
of
16
significant
including overstruck characters
is a character
character
constant,
constant.
constants
a pair
constant.
are displayed,
of
quotes
For
example:
The
must
quotes
or
be
DON'T
'DON'
GIVE
'T
THE
GIVE
THE
ANSWER
ANSWER
AWAY
AWAY'
31
Page 36
Logical
Data
Logical (Boolean)
(>
~
= <
true
and
to
the
Logical
treated
SCALAR
A single item,
It has
ing
are
A
Scalars can be used
The
variable
~:;t)
generate logical
0 if
the
condition
logical
functions
data
can also be used
as numeric 1's
whether
no
coordinates;
examples
• A I
,,,'
name
of
data
and
that
scalars:
directly
for
the
consists
data
was false.
(/\I\vv",)
with
D's.
a single
is, it
in calculations
scalar can
of
only
as
their
to
check
the
number
can
be
then
ones
and
result;
The
output
for
arithmetic
or
single
thought
or
be used
zeros.
The
the
result
can
then
be used as
certain
conditions
functions,
character
of
as a
can be assigned
in
constant,
geometric
the
calculations:
relational
is
1 if
in which case it
to
functions
the
condition
arguments
being
true
is
called a
point.
The
a variable name.
or
false.
is
follow-
was
scalar.
I.>
c·
.J
ARRAYS
Array
is
the
items), vectors (strings
dimensions
arrays.
Indexing,
Some
2x3
l~f'2
Bi"~:~
(.·~+B
general
(multiple
for
term
of
tables). All primitive (built-in)
functions
example, can select
for
a collection
data),
matrices (tables
are designed specifically
certain
of
data,
elements
and includes scalars (single
of
data),
and
arrays
of
higher
functions
to
handle arrays
from
an array
are designed
rather
than
for
processing.
data
to
handle
scalars.
32
Page 37
One
of
the
simplest kinds
thought
bers
can be selected from a vector
sion.
variable names,
present:
that
The
of
indicate
following
as a collection
the
Nand
of
of
positions
example
C;
the
arrays,
the
vector, has only
elements
by
shows assigning a numeric
names are
arranged along a horizontal line.
of
elements
a single index, since a
then
in
an
array are called indices. An
entered
to
one
dimension; it
vector
has
only
and a character
display
the
values
can
The
one
vector
they
be
num-
element
dimen-
to
re-
two
(
N~5
N
6.2
-::5
C~"
·
~;
c
ABCDEFG
Generating Arrays
The
most
common
the
array
is
to
ments
of
the
function.
used
the
number
the
blank.
right
'one dimension (is a vector) seven
be supplied
matter
fewer
seven entries in
are used.
The
to
generate a n array
values for
for
each
coordinate.
The
values
argument
from
how
than
seven elements, its
The
way
have-that
new array.
symbol for
the
elements
coordinate
Each
of
(Y).
whatever
many
elements
the
new vector. If A has
following examples
6.2
-3
888
aB8
(y~;.
:1.2
ABCDEFG'
to
generate an array
is,
the
length
The
APL
function
the
reshape
is
X p
Y,
where X
of
the
array.
to
be generated;
number
the
The
in
the
left
elements
instruction 7 p A means
values are
of
elements
A has, as long as it has at least
elements
show
95.12
is
to
of
each
coordinate;
that
function
the
found
are repeated as
generation
is
is
the
For
the
this
argument
new array are
in length,
stored
more
than
specify
the
forms
an
array
p.
The
format
shape
of
the
left
argument
number
that
indicates
must
be
whatever
the
array
and
that
under
the
one
often
seven elements,
of
some
following:
the
values
is
array and Y represents
(X),
separated
you
to
seven values are
name
element.
as needed
vectors:
the
of
the
the
reshape
of
the
function
you
enter
the
length
by
at
enter
be
generated has
A. It
does
If A has
to
provide
the
first seven
shape
ele-
least
as
a
of
one
the
to
not
('
c
7(.>:1.
2 ]
:1.2:.3123:1.
2p12~5
123
:1.23
5(.)1
.
~5
1.3 1.3 1.3 1.3
An array with
two
Columns
coordinates
(rows
Rows
1.3
and
columns)
is
called a
matrix.
33
Page 38
To
generate a matrix,
lengths
ordinate,
coordinate,
generated:
of
or
:1.
2 3
I.~
~;
the
number
or
(o1BCB
EFGH
ABC
DEF
Note
that
the
the
right
argument
argument
The
required
a
rank
(where N
providing
(planes, rows,
3-rank
in
row
in
rank
of an
to
locate
of
1,
matrices have a
is
equal
as
the
arrays.
order:
I~IBCD
EFGH
I,.JKI...
you
two
coordinates.
number
M~2
specify X (left
of
rows, and
of
columns.
3pi
The
the
2 3 4 5 6
first
second
The
argument)
number
number
following
as
two
in X
is
is
the
example
numbers,
the
length
length
shows
which
of
the
of
the
how a matrix
t-1
6
t.1f-2
1+
r
I
ABCDEFGH
J
I
M
M
:1.
i-
2
:.3 p t1
Mi
values
in
the
right
argument
has
more
than
one
row
order.
array
is
the
number
any
element
to
the
left
argument a number
and
columns).
Note
that
A~'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;.~
:5
lJ.
P(.~I
\.
____
within
rank
of
rank). N-rank arrays, like matrices, are
The
following examples
the
elements
2-plane, 3-row,
row,
of
coordinates
that
2,
and
indicating
taken
are arranged
the
elements
array. Scalars are
N-rank arrays have a
from
in
are
it has,
the
length
show
the
right
4-column
row
taken
or
the
how
argument
array
order
from
number
rank
O.
rank
generated
for
each
to
in
the
the
of
Vectors have
from 3 to
coordinate
generate
are arranged
are
first co-
second
arrays. If
right
indices
by
the
is
63
34
MNDP
f~I~ST
UVWX
'+
AB
CD
EF
GH
IJ
1{1...
~1N
DP
GR
ST
UV
WX
3 2
\\-
f)l~
___
4-plane, 3-row,
2-column
array
Page 39
Finding the Shape
of
An
Array
(
(
Once you
each
is
the name
sult
length (number
is
always a vector:
The
have
coordinate)
of
is
one number
shape
of a matrix
A~111
~)
123
'+
5 6
2 3
12~3ll·
~5
6
·7
1 2 3
generated
by
the array.
of
(.1
M~2
an
array, you can
specifying p (shape function)
If A is
a vector
because A is
elements)
222
or
3p1
a one-dimensional array. The number
of
A's one dimension. The result
333
N-rank array
2 3
M
~)M
R~2
3
4pi
2 3
R
B
Lt·
1+
444
is
5 6
1+
find
its
with
six elements
555
found the
5 6 7 B
shape
with
666
same
(number
only
and
way:
of
elements in
a right argument which
you enter
is
6, the
of
the
shape
pA,
the
function
re-
~5
6
"7
B
3
2
1
~.)
Lt·
t)
"7
B
pR
'i
3 4
.:..
I n
some
cases,
it
might
be
necessary
nates (or
shape)
indice~)
and a right argument, which
of
Ai-lll
Bf·2
Ci-2
(jA
an
array. The rank
222
3p1
2
I.~~)
1
~3
6
ppA
1
,,,
(
/
2 3
pH
p(jB
2
pC
1+
3
2
ppC
3
to
know
can
is
the name
~5~53
4'+'+
3
~i
'+
,+
:~
3
just the rank, the number
be
found
by
entering pp
of
the array:
6
~)
of
(shape
coordi-
of
the
35
Page 40
The
following
arrays:
Data
Type
Scalar
table
shows
Shape
No
dimension
what
pX
the
shapes
(indicated
and
ranks are
by
an
empty
for
the
vector).
various
Rank p pX
·0
types
of
Vector
Matrix
N-rank
arrays
Empty Arrays
Although
exist.
An
when
creating lists (see Catenation in
defined
Following are
• Assign
function
-------------
0,
'-.
____________
most
arrays
array
with
(see
some
ways
10
to
a variable
EVECTOR-E"
[VECTOR
r:iEVECTOR
Number
Number
number
Each
have
one
no
elements
Chapter
to
name
of
elements.
of
rows
is
or
more
is
6).
generate
to
generate
\.0
and
the
the
length
elements,
called an
this
chapter)
empty
An
by a blank
The
is
zero
number
empty
arrays:
an
empty
shape
of
of a coordinate.
arrays
array.
or
when
empty
vector:
array
display.
of
the
(zero
elements).
columns.
with
no
Empty
branching
is
indicated
empty
2
N
elements
arrays are useful
vector
also
in a user-
36
• Use a zero length
EMATRIX:l.~<3
EMATJ~IX:1.
~)EMAT
:3
0
• A
function
shape
of
a scalar:
might
coordinate
J~
I X
1.
generate
A
when
an
empty
blank
generating a
O~)
\
0-
vector
output
multidimensional
This
and
A
blank
as its result;
display.
matrix
no
(0)
output
has
three
columns.
display
for
example,
array:
rows
finding
the
Page 41
CATENATION
(~:
You can join
function. The symbol
or scalars and vectors,
fied,
as
together
the
following examples show:
A~~
1.
:~
5 6
Bi"'+
A,B
:l
:3
2
'+
'+
1::'
\.1
B,A
q.
~:;
6
1.
2
:.:~
(4,2
:1.
2 3
3
1-
When catenating
A,[I]B, where I defines
If
the
coordinate
matrices and [I]
is
[2],
the
show
how
'+
3/A
'1
r:M
3
last
coordinate
to
catenate
2
1+
two
is
is
not
[1],
two
arrays
to
make a single array by using
for
this
function
the
variables are joined
I.~
:3
is
6
q.
matrices
the
matrices:
or
N-rank arrays,
the
coordinate
specified,
first coordinate (number
(number
that
the
last coordinate
of
columns)
the
catenation
the
comma. When catenating vectors,
in
the
order
the
will be
is
function
expanded
is
used. When A
of
rows)
expanded.
in which
they
can
take
the
when A and
and
is
expanded; when [I]
The
following examples
are speci-
form
B are joined.
Bare
c~
(".,
-
./
("
1.0
20
~!50
'+0
~~
10
~7j
4·0
10
20
I.~O
~5
"")
I!.
1.1-
1::-1::'
..
J ,.J
1+'+
Ai"2
B~"2
A,B
30
60
A/[2:JB
()
30
0
60
A/[lJB
30
()
60
")
A-_
:3~1
66
:3~):1.
0
20
3(-1l.:1.
1:1.
'+'+
:1.1
'+'+
,')
Lot!.
55
22
55
")
22
33
66
33
66
,
:3
()
:3:3
4·0
1.1.
Graphic
A B
!!.!j
0
<~)
0
"':'I:!'
1
+
,.J ,.J
66
-
A
B
10
40
10
40
20
50
A
20
50
10
40
11
44
30
60
30
60
20
50
22
55
Representation
11
44
B
11
22
44
55
30
60
33
66
22
55
33
66
33
66
(~
37
Page 42
A~-2
B~··2
(.1
:1.
0
20
1.1-0
~.:;O
LENGTH
~5(.)tO
'+.otl.
~
[2:JB
30
1.
:I.
1::·1::·
(~)
()
d,J
A,[lJB
ERr~DR
A~
[:I.J
Matrices
ordinates not specified are
ordinates not specified are
following):
::.::~.~
l)(~)
20
30
:·5~3
~~2
:·5~~
77
of
unequal sizes can be catenated, providing ,that
1.,·0
~:;
0
,::.,:.-
,.J
,J
4·'+
'+'+
•
BB
B
60
61.)
the
same (see
not
the
77
the
first example following).
same, an error results (see
10
88
40
A
10
40
A
B
the
lengths
the
second example
20
50
20
50
10
40
11
55
30
60
30
60
of
20
50
22
66
If
the
the
co-
11
55
30
60
33
77
co-
11
55
22
66
44
88
22
66
33
77
33
77
44
88
B
44
88
A scalar can also be catenated
catenated
to
a matrix. Notice
A~2
3pl0
A
10
20
30
'+0
~50
60
A,[2J99
1.0
20
30
99
l~O
50
60
99
A,[:LJ99
10
20
30
'+
0
~7j
()
6
()
9("/
99 99
A vector can also be catenated
matches
10
1.1·0
the
length
(.1,99
20
~50
of
the
88
::~()
99
ld)
8B
coordinate
•
to
that
20
to
an array.
the
scalar
30
~O
another
not
In
the
following example, a scalar
is
repeated
50
60
array, provided
specified. See
,
10
40
to
complete
the
the
following examples:
20
30
50
60
the
length of the vector
99
88
is
coordinate:
38
A/t:l]99
LENGTH E R
A/[l]
A
I~O
R
99
88
88
Page 43
(
The
catenate function
necessary
create a matrix named PHONE where each row will represent a 7-digit telephone
number. First
at
PHONE with no (0) rows and seven colum-ns:
to
use an
you
a later time. The following instruction will establish
is
useful when creating lists
empty
array
to
start
want
to
establish
the
of
information. Sometimes it
a list. For example, suppose
matrix, then add
an
the
telephone
empty
array named
you
numbers
want
is
to
_---I:->H-O-N-E-:
o
'7
Now,
the
5336686
~:;:3366B6
45e)I+7'7l
2
\_7
INDEXING
PHDNE~"O
pPHONE
telephone
PHONE~PHONEIC1]'5336686'
7(.>·~
0
_______
numbers can be added as follows:
Blank display indicates an
empty
PHONE
PHONE~PHONE/C1]'4564771'
PI··IONE
pPHONE
___________
The list of
now
contains
array.
telephone
two
numbers
rows.
c
You may
Referring
integers;
to
14 15 16 17. The result
A [2]
the
Here are some more examples
not
to
d,nly certain elements
they
which
they
is
12 (assuming
index origin).
want
to
refer
are enclosed
apply. Assume
of
the
index origin
A~11
12 13
to
in
entering A
A[3]
A[~:;
:3 7 1]
15
13 17
11
Bi":~
~I.
'+
ACB]
13
1:1.
:1.4
16
B~'ABCDEFGHIJKLMNOPQRSTUVWXYZ
8[4
1
1~
DAN
AND
CI...A
I
I~
C~22
9
18
BEG]
VIRGINIA
the
whole array
is
called indexing. Index numbers must be
brackets and written after
that A is
is
is
of
indexing:
l4
15
6 Blank Character
but
just
to
certain elements.
the
name
of
the
variable
assigned a vector as follows: A+-11 12 13
the
whole vector, and
1; see Chapter 5
16
17
the
result
for
more information
of
1
·
27 1 14 4 27 3 12
7 9
14
9 1
1 9
18J
entering
on
39
Page 44
If
you
use an index
instruction
cannot
that
be
executed
refers
to
A
11
12
13
1~
15
16
A[8]
INDEX
ERROR
ACBJ
A
You
cannot
specified. For example, suppose
then
error, since those elements
VALUE
an
index or
attempt
do
to
store
Z[3
I.J·]~":I.B
ErJ.rJ.D'~
Z
I::
3
I~.
::I
/'0.
anything else with an array until
values
do
not
~..
:1.
B
an
element
and
INDEX ERROR results:
that
does
not
exist in
17
after
the
that
no value has been assigned
in
certain elements within Z would result
exist:
'+6
I.).
b
to
the
array,
the
array has been
the
name Z;
in
an
/ '}
"
....
,
13
3 7 3
l..OOI(
Indices (whatever
those
expressions are finally evaluated,
indices for
the
is
array:
inside
the
brackets) can be expressions, provided
the
results are values
B
ABCDEFGH
I
,..II{
X~-1
2 3
I...MNO
P(~
4·
RSTUVWXYZ
~:=;
B[Xx2]
BDFH,J
X
1 2 3 ~ 5
B[1+Xx:~J
The
array from which elements are selected
example, a vector can be indexed as follows:
2 3 5 7 9 11
13 15
17
does
19[7
'ABCDEFGHIJKLMNOPQRSTUVWXYZ
PA
not
have
2 ~ 2]
'[12
that
represent valid
to
be a variable.
15
15
that
11
when
For
27
16
1]
,40
nDN
r'i(.:,R\'
•
{i
BCD E F 0 H I
-~------
,"/1<
I...
r"'1
______
N
[I
P
(-).
F-~
STU \/
t·
.
.!
X '{
:?:
'I::
:::.:~
1+
(,1+
1
~.:.:.i
ll.j·
"':,":.1
......
I
:I.
:::~;
:I.
J D
::?
~.:.:.i
J
~~
~
~
The
shape
of
the
result
is
the
same as
the
index.
Page 45
(
Indexing a matrix
The index numbers for each coordinate are separated by semicolons. Suppose M
a 3 by 4 matrix of consecutive integers:
M~3
or
N~rank
array requires an index number
4p1
2 3 4 5 6 7 8 9 10 11
f<;>r
each coordinate.
12
is
(
If you ask
1.
~5
9
1.0
If
you
want
If
you
want
..,
8
Similarly,
to
M
r)
~
6
to
see
the
~z
..
)
..,
(
11
to
refer
M[2;3J
to
refer
refer
values
I.f.
8
r)
1
~
to
the
to
the third and
to
the
elements
of
M,
they
element
are displayed
in
row
2,
column 3,
fourth
elements
in
column 4, rows
in
the
usual matrix form:
you
would enter:
in
that
row,
1,2,
and 1,
you
would enter:
you
would enter:
("/
c
I.f.
8
L\.
You can use
matrix
of
those
enter:
MI:2
~)
6
9
1.0
If
you
do
not
array
that
you are indexing, APL assumes
For instance,
5 6 7 8
the
same procedure
elements
3;1.
c'
oJ
2
to
select a matrix within a matrix.
in
rows 2 and.3 and columns
1]
9
specify the index number for one or more of
that
you
want
to
get all of row 2,
you
would enter:
MC2j]
1,2,
and 1 of
the
coordinates
the
entire coordinate(s).
If
M,
you
you
want
would
of
the
the
41
Page 46
Or
to
l.J.
B
:1.2
get all
M[
:I.
5
9
of
columns
i
'0I-
4 and 1,
l.
]
you
would
enter:
Note: You still have
The
number
number
of
semicolons required
of
semicolons
Mt<5
pM
3
L~
Mr.6Jf·9
R(~NK
You can change
elements. (The rest
:I.
1+
....
t'
l
I.,.
7
")
4-
I::'
d
B
••
:1.0
ERROR
M[6]t-9
elements
A~3
A
3
b
'1
(:l[
2 i
f~
'i
::5
.'"0.
:~~
0
':~
B
to
enter
the
semicolon
is
is
not
specified, RANK
LI·p\:L2
within
an
array
of
the
array remains unchanged.)
3p1
2 3 4 5 6 7 8 9
::.~
:3]~-lO
20
to
make clear which
the
rank
of
the
ERROR
by
assigning new values
coordinate
array minus one.
results:
for
If
the
is
which.
the
correct
indexed
42
Page 47
APL
functions
language. User-defined functions are discussed
called primitive functions, are
supply
to
them.
are
of
two
types: user-defined and
denoted
by a symbol and
Chapter 4. Primitive (Built-In) Functions
those
that
are built
in
Chapter 6. Built-in functions,
operate
on
the
into
data
the
you
APL
(
The value
two
are said
be single
multiple tables
defined
There are
There
functions
are set
or
values
arguments, such
to
be monadic, such
data
items (scalars), strings
of
data
functions
two
are also
and
up
as
that
types
operators
operators
they
would appear
you
supply are called arguments. Primitive functions
as
A";-
B,
are said
as";-
B,
(N-rank arrays). Arguments can also be expressions
result
in
a scalar, vector, matrix,
of
primitive functions: scalar functions and mixed functions.
that
operate
are provided
on
PRIMITIVE SCALAR FUNCTIONS
Scalar functions
arrays
element
pend
on
the
lation
between
following table. Each scalar
Argument A
operate
by element.
shape and rank
tile
types
on
of
scalar arguments and arrays.
The
shape and rank (see
of
the
arguments.
arguments
function
Argument B
to
be dyadic;
which yields
of
data
(vectors), tables
on
the
primitive functions. Examples
throughout
the
display.
For
and
the
shape
is
described following
functions
the
reciprocal
this
chapter
Chapter
dyadic
of
that
use
of
B.
Arguments can
of
data
(matrices),
or
N-rank array.
for easy reference and
They
are
extended
3)
of
the
scalar functions,
the
result
is
shown
the
table:
Result
that
one
argument
or
of
to
result de-
the
in
the
use
or
user-
the
re-
(~
('"
Scalar Scalar Scalar
Array Array with
shape as A shape
Scalar
or
one-
element
Array
any
One-element One-element array
array with
array shape same shape as
of
shape element array shape
Array
Scalar
different
rank
the
same Array with
of
any
or
one-
the
rank with
from
the
of
A
arguments
Array with
argument B
Array with
One-element array
the
array with
greater rank
as
the
as
argument
the
shape
the
the
the
same
same
A
of
the
43
Page 48
The + Function: Conjugate. Plus
[]
/
Monadic (One-Argument) Form:
The
conjugate
numeric scalar, vector,
of
the
argument:
c·
.J
If B
is
an
the
result
array,
is
the
B~2
function
A~"
'H~:;
+(.~
the
function
shape
3p-3
does
or
of
B:
B
H'~3
'''2 '-l.
(}
1-
2
+B
-2
'-1
Conjugate
not
other
array, and
is
extended
-2
change
-1
+8
the
argument.
the
shape
to
each
0 1 2
of
of
the
The
argument
the
result
elements
is
of
can be a
the
B.
same
The
as
that
shape
of
Dyadic (Two-Argument) Form:
The
plus
function
results in
numeric scalars, vectors,
one
of
the
same shape,
arguments
the
is
result has
3+~3
6
5.73
:1.
:1.
Plus
the
or
other
a scalar
the
'W
:1.
A+B
sum
of
the
two
arguments. The arguments can be
arrays. Arguments must be
or
single-element array.
same shape as
N'
~3
+~.l.
the
arguments:
2
()
'+
the
If
the
arguments have
same shape, unless
the
44
Page 49
(~
(~
If
one
as
of
that
the
:l.
LI·
argument
of
multielement
...
)
......
5
the
Bf·2
B
~3
6
is
other
a scalar
input
array:
:.3
(.>:1.
or
single-element array, the shape
argument.
'")
,:..
The
.7.
I::·
,.I
,.)
4·
6
3+B
6
4-
~5
9
7 B
B+3
!5
6
'4·
·"1
(
9
8
The - Function: Negation, Minus Q
single element
is
applied
of
the
result
to
every
is
the
element
same
Monadic (One-Argument) Form: Negation
The
negation
numeric scalar, vector,
the
argument:
function
A~-·:J.
changes
or
·":3
other
the
sign
array.
A
···3
·":1.
····I~
If
the
argument
is
B~2
an array,
3p-3
the
-2
function
-:I. 0
B
-3
···2
-1
o
:J.
2
..
MB
:3
2
-1
:I.
-2
()
-8
of
The
is
the
argument.
shape
extended
:I.
2
of
the
to
The
result
each
argument
is
the
element
same
of
can be a
as
that
the
array:
of
45
Page 50
Dyadic (Two-Argument) Form: Minus
A-B
The
minus function subtracts argument B from argument
numeric scalars, vectors,
one
of
the
less
are
the
arguments
same shape, the result has
~:~""2
or
is
other
arrays.
a scalar
the
The
arguments must be
or
any single-element array. If
same shape as
:I.
1+····~5
'+'-
'''~:5
9
2 0
If
one
same as
element
argument
that
of
is
a scalar
of
the
the multielement array:
B~2
or
other
input argument.
3p1
2 3
a single-element array,
~
5 6
The
single element
B
:l
2
~5
1+
5 l)
:~"MB
2
:I.
0
"'1 '-2 "'3
B-'3
'-2
-':1.
0
1.
:?
:3
the
arguments:
-1+
the
shape
A.
The arguments can be
the
same shape un-
the
arguments
of
the
result
is
applied
to
every
/ "
I~.
)1
is
the
46
The x Function: Signum, Times (IJ
Monadic (One-Argument) Form: Signum
The
signum function indicates
- 1
is
the
result;
if
the
argument
tive, 1
is
the
result. The argument can be a numeric scalar, vector,
The
shape of
the
result
is
the
same
the
is
xB
sign
zero,
as
that
of
"':l 0 1
the
argument:
then 0 is
of
the
if
the
result; if
argument:
the
argument
the
is
argument
or
other
negative,
is
posi-
array.
Page 51
If
the argument
is
an
array, the function
is
extended
to
each of the elements:
(
B~2
-~~
1 2
-1
3p-2
B
0
~5
-1
xB
"'1
-1
0
1
:I. :I.
Dyadic (Two-Argument) Form: Times
The times function result
arguments can
the same shape, unless one of the arguments
Arguments of the same shape
be
numeric scalars, vectors, or other arrays. The arguments must
is
the product of argument A times argument
have
2x2.1
4·
. 2
2
1+
6.1
12.2
"'16
0 1 2 3
AxB
is
a scalar or any single-element array.
the same shape result:
-1+
B.
The
be
If
one argument
as
same
element of the multielement array:
that of the other input argument. The
is
a scalar or a single-element array, the shape of the result
B~2
3p1
2 3 ~ 5 6
B
:I.
2 3
'+
5 6
3xB
369
:1.2 :1.5
18
single
element
is
applied
to
is
the
every
47
Page 52
The"," Function: Reciprocal, Divide
CD
Monadic (One-Argument) Form: Reciprocal
The
reciprocal
a
numeric
the
argument:
O
If
the
I::'
....
,
argument
function
scalar, vector,
is
B~-2 2 ~)2 . ~5
result
or
an array,
is
other
the
the
reciprocal
array.
function
B
2 0 .
2 0 .
'~'H
o .
~:5
o .
!:j
~:;
~,:;
-;'-8
The
shape
is
extended
of
the
argument.
of
the
to
result
each
of
The
is
the
the
elements:
argument
same as
can be
that
of
Dyadic (Two-Argument) Form: Divide
The
divide
function
The
arguments can be numeric scalars, vectors,
be
the
same
shape unless
Arguments of
,.,
,:.,
:I.
•
~5
If
one
argument
same as
element
that
of
B~2
of
the
result
is
the
one
of
the
same shape have
is
a scalar
the
l)1ultielement array:
2p1
other
or
a single-element array,
input
10 20
argument.
B
:I.
10
20
lOO
~5+B
~3
o .
:J.~;
0.3
()
.
():~
A-;'-B
quotient
the
when
arguments
the
same shape result:
:1.00
argument.A
or
is
The
single
other
a scalar
the
element
is
divided by
arrays.
shape
The
arguments
or
a single-element array.
of
the
result
is
applied
to
argument
must
is
the
every
B,
\~,
48
Page 53
(~
(
Note:
There
are
two
additional
When
zero
is
1.
2.
:1.
Any
()
value
..
:.
0
other
divided
than
by
zero
zero,
3+0
DOMAIN
ERROR
:'5'~"
0
,
....
The rFunction: Ceiling, Maximum
rules
that
the
cannot
OJ
apply
result
is
be divided
to
1 :
the
by
divide
zero:
function:
I
('
Monadic (One-Argument)
The
ceiling
function
is
rounded
the
array.
same
The
up),
as
shape
unless
the
argument.
of
'+
If
the
argument
:1.
2
2 2
B~2
B
1
is
an array,
Form:
result
the
2pl
the
result
1.3
is
argument
The
Ceiling r B
the
next
already
argument
is
the
same
the
function
1.5
1.
•
:'5
integer larger
is
an
integer. In
can
be a numeric
as
that
of
is
extended
2
than
the
argument:
to
each
the
argument
this
scalar, vector,
of
case,
the
elements:
(the
the
argument
result
or
other
is
Note:
The
result
Chapter 5 for
of
the
ceiling
information
on
function
the
OCT
depends
system
on
the
variable).
OCTsystem
variable (see
49
Page 54
Dyadic (Two-Argument) Form: Maximum
The
maximum
numeric scalars, vectors,
one
less
same shape have
of
function
the
arguments
result
or
other
is
a scalar
the
same shape result:
is
the
arrays.
3
-·I.)r···:1.0
'''6
'-:1.
'-3 r
~:.=;
a single-element array,
~5
'+
If
one
argument
same as
of
that
the
multielement array:
:L
:3
2
r.:'
1+
,J
I.>
"7.
.J
::3
3
I::'
,J
6
'+
~j
•
:1.
is
of
the
Bi··2
B
~5r
B
a scalar
other
3p:1.
or
argument.
2
ArB
larger
of
the
The
arguments
or
any
single-element array.
• j.
The
I::'
,J
single
6
o
element
arguments.
must
"'4-
the
shape
is
applied
The
arguments can be
be
the
same shape un-
Arguments
of
the
result
to
every
of
the
is
the
element
50
Page 55
(
(
The L Function: Floor,
Monadic (One-Argument) Form:
The
floor
function
is
rounded
is
the
array.
down) unless
same as
The
shape
the
Minimum
result
argument.
of
the
result
3 "'3
LI.I·
If
the
argument
is
B~2
B
an array,
2pl
1-
1.6
LB
1 1
:1.
2
Floor
is
the
next
the
argument
The
is
the
the
function
1.5 1.6
:I
2
LB
integer smaller
is
already an integer.
argument
same as
is
2
.•
~5
than
the
argument
In
this case,
can be a numeric scalar, vector,
that
of
the
argument:
extended
to
each
of
the
elements:
(the argument
the
result
or
other
c
Note: The result
Chapter 5 for information
Dyadic (Two-Argument) Form:
The
minimum
numeric scalars, vectors,
less
one
of
the
same shape have
of
the
function
a~guments
the
same shape result:
1+1
..
6
1+
2
'-fo)
I..
"'10
"'1.0
5 . 1
-1,
5
.1
"'4·
floor
on
Minimum
result
or
other
is
a scalar
-:I.
function
the
is
the
'-:31
depends on
OCT system variable).
ALB
smaller
arrays.
or
..
5.1
of
The
any single-element array. Arguments
the
the
arguments.
arguments
OCT system variable (see
The
arguments can be
must
be
the
same shape un-
of
the
c
51
Page 56
If
one
same as
of
the
t
1+
:t.
:05
argument
that
multielement
000)
,.
...
0
1::
,J
2
:3
is
of
the
Bioo::o~
B
ooz
'0)
I:>
:sl..
B
-1,
'\.0)
:3
a scalar
other
array:
3(.):1.
or
a single-element array,
argument.
2
:05
1+
The
1::.
'oJ
single
(:)
the
element
shape
is
applied
of
the
to
result
every
is
the
element
"~,
))1.
The I Function: Magnitude, Residue
Monadic (One-Argument) Form: Magnitude I B
The
magnitude
can
be
a numeric scalar, vector,
that
of
as
the
argument:
function
result
is
or
CD
the
absolute value
other
array~
100('.9
7.9
100.3
3
If
the
argument
B~2
is
an
2p-S.t
array,
the
-t
function
0
3.t4-
is
B
0.0~5
• 1
o
IB
~o:j
•
:I.
00.:1.
:.:~
. 1
'+
o
The
extended
of
the
shape
to
each
argument.
of
the
result
of
the
The
argument
is
the
elements:
same
52
Dyadic (Two-Argument) Form: Residue A I B
The
residue
the
remainder when
apply
1.
function
when using
If
argument A is
result (when
argument B is
the
residue
equal
both
divided
function:
to
zero,
argument
then
016
6
by
argument
the
result
A and
is
argument
A.
The
equal
B are positive)
following rules
to
argument
is
B:
Page 57
(
2.
If
argument A
argument A and zero (the result can be equal
argument A).
a.
When argument B
from argument B until a value between argument A and zero
is
The
not
result
equal
to
zero,
is
obtained as follows:
is
positive,
:315
2
then
the
the
absolute value
result
to
'zero,
is
a value between
but
not
equal
of
argument A is
to
subtracted
is
reached:
(~
c
b. When argument B
argument B until a value between argument A
is
negative.
1
The
arguments can be numeric scalar, vectors,
be
the
same shape, unless
array. Arguments
one
of
the
same shape have
of
the
:317
:I.
:":~
1 6
0
61
:3
3
()
17
7
71
0
0
-"21
12.
~5
""":I.
.7
"-21
""":1.2.
~3
-0
.
~5
-'12.3
21
1
.7
1
12
.
~:~B~5
.
:3B~)
0
"""~?
•
1
:3B~:=j
•
6:1.~)
0
:1.
the
absolute value
arguments
the
of
argument A is
and
zero
or
other
arrays.
is
a scalar
same shape result:
or
any single-element
is
reached:
The
arguments must
added
to
c
C
If
one
argument
same
as
that
of
the
multielement array:
3
1 2
6
~5
'+
0
:I.
2
()
:1.
2
of
the
B'""2
B
31B
is
a scalar
other
:3(.>:1.
or
a single-element array, the shape
argument. The single element
'")
:'5
-:-
'+
/.)
~:)
is
applied
of
the
to
result
is
the
every element
53
Page 58
The * Function: Exponential, Power
Monadic (One-Argument) Form: Exponential
The
exponential function result
to
the
power indicated by
vector, or other array.
The
is
the
Naperian base e (2.718281828459045) raised
the
argument. The argument can be a numeric scalar,
shape
of
the
*:1.
2.71.B:3
')f3
20.0B6
If
the
argument
is
an array,
Bi··~?
2pO
the
1.
function
2
:~
13
()
1
2 3
*B
~?.
1.
7.389:1.
Dyadic (Two-Argument) Form: Power A * 8
The power function result
B.
The
argument
arguments must be
single-element array. Arguments
arguments can be numeric scalars, vectors,
is
the
same shape unless one
7:1.8~5
20
. 08l)
argument A raised
of
the
*8
result
is
the
same
is
extended
same shape have
to
of
to
the
power indicated by
the
arguments
as
that
of
each element
or
other
is
a scalar,or any
the
same shape result:
the argument:
of
the
array:
arrays. The
0.25
1
3
o .
:I.~?'5
The
root
the
reciprocal
by
:I.
2
2~'3
...
-------2*-3
of a number can be found by raising
of
the
root. For example,
:1.
'+'
<j
:I.
6·)f··:··2
~5
'+
= 1/23 = 1/8 = .125
to
the
find
number
the
square root:
to
the
power indicated
54
Page 59
(
(
("
The
If
one
argument
same
as
that
of
the
multielement array:
:L
2
~5
1+
of
the
B~"2
1-3
1.
is
a scalar
other
2(.>:1.
or
a single-element array, the shape
argument. The single element
2 3
4·
9
...
Function: Natural Log, Logarithm
The
~symbol
is
formed by overstriking
CD
the
0 symbol
of
is
applied
CD
and
the
* symbol.
the
result
to
every element
is
the
c
(""
Monadic (One-Argument) Form: Natural Log
The natural log function result
(2.718281828459045).
or
other
array. The shape
m2.7:1.B3
1.
m~.?O
. OBb
is
an array,
2(.>:1. 3 :1.0
If
..
.,
,:)
the
argument
Bfo2
is
the
log
The
argument can be a non-negative numeric scalar, vector,
of
the
result
the
function
20
B
:I.
3
to
20
wB
o
2.3026 2.9957
1.0986
~B
of
is
the
is
extended
the
argument B
same
as
that
to
of
each
to
the
the
argument:
element
Naperian base e
of
the
array:
Dyadic (Two-Argument) Form: Logarithm
The logarithm function result
The
arguments can be numeric scalars, vectors,
be
the
same shape, unless
of
the
Arguments
same shape have
one
is
of
the
the
the
2m8
2 3
'+(+)8 9 :1.6
322
Ae
B
log
of
argument B
or
other
arguments
same shape result:
is
a scalar
to
the
base
of
argument A.
arrays.
The
arguments
or
any single-element array.
must
55
Page 60
one
If
same as
of
the
1 2
:3
argument
that
multielement
is
of
the
B~··2
B
1+
a scalar
other
array:
2p1
or
a single-element array,
argument.
2
:3
ll·
The
single
the
element
shape
is
applied
of
the
to
result
every
is
the
element
o
0,1+771.2
The 0 Function:
Monadic (One-Argument) Form:
Thepi
times
argument
the
same
3,
:1.
(7
,4·24·8
If
the
argument
1.
2
3
1+
Pi
function
can be a
as
that
of
01
1
+16
o:~
is
B~··2
B
(:)B
:~,
11+16
9,1+24·8
Times, Circular
result
numeric
the
argument:
an array,
2~):t
(),:5010~3
0,60206
CD
Pi
Times 0 B
is
the
value
of
scalar, vector,
the
function
2
:3
ll·
6,28:52
1.
2 ,
or
is
:::;66
pi
(3.141592653589793)
other
array.
The
extended
to
each
shape
element
times
of
the
of
the
B.
The
result
array:
is
56
Dyadic (Two-Argument) Form: Circular
The
circular
(argument
numeric
one
less
same shape result.
related
of
a positive
will result
function
A)
for
the
scalars, vectors,
is
a scalar
functions
in
or
The
performed.
argument
DOMAIN
result
is
the
specified radians
or
other
single-element array.
following
A negative
A;
any
values
ERROR:
Ao
B
value
of
(argument
arrays.
is
Arguments
a list
of
argument A is
for
argument A other
the
specified
B).
Arguments
the
values
trigonometric
The
arguments
must
be
the
of
the
same shape have
for
the A argument
the
mathematical
than
function
can be
same shape, un-
and
inverse
the
following
the
the
Page 61
Value
of
A
Operation Performed
(
('
008
loB
208
308
408
508
608
708
Cosine 8
Hyperbolic sine
Hyperbolic cosine of 8 (cosh 8)
Hyperbolic tangent of 8 (tanh 8)
Arcsin 8
Arccos 8
Arctan 8
of
B (sinh 8)
(~
(:
Arccosh 8
Arctanh 8
If
lent
0
8
is
45
here
is
how
to
,
to
pi
radians divided by 4):
B~"o":"1+
B
o I
7B~54·
o .
707:1.1.~.------_Sine
O.70711
1.
~.-----------Tangent
/,-------the
:loB
20B
..
·------Cosineof8
:~()B
solve for the' sine, cosine, and tangent of 8 (450 is
The
left argument specifies
trigonometric function.
of 8
equiva-
of 8
c'
57
Page 62
If B is
the sine of an angle, then OoB yields the cosine of the same angle, and con-
if B is
versely,
0
,
30
which
o .
o .
o .
•
O
If
one argument
as
same
the cosine, OoB yields the sine. Suppose you wanted the sine of
is
equivalent
H'"':l
B
~3
~.-----------Sine
Oe)B
B660:3~>4---------Cosine
B~-20
B
BI.>603~.---------Cosine
Oc)B
t!!-~.
___________
\J~
is
that
of
the
to
pi
divided by 6:
()
(c)-~-6)
0
of
30
0
of
30
«)":--I.>
)
0
of
30
Sine of
30
0
a scalar or a single-element array, the shape of the result
other argument. The single element
is
applied
to
of the multielement array:
A'""2
2(.>:1. 2 :-5
Bt-t")--;·1+
4·
A
is
the
every element
()
.
7B~5'+
0.7071:1.
t
AoB
()
.7071
:1..2716
:1.
58
Page 63
(~
The!
Function: Factorial, Binomial Q 0
The!
symbol
Monadic (One-Argument) Form: Factorial !B
The
factorial
the
number
vector,
or
is
function
value
other
formed
of
the
array.
by overstriking
result
is
the
argument.
The
shape
of
the
product
The
the
p+
24-
:l.X2x3X4-
24-
,')
.:..
l.
6
The
factorial
integers are
of
the
7.173~5
not
mathematical gamma
!1
2
function
! 3 . 1
:~
2
4-
1
.1.
120
also works with decimal numbers
allowed. When used
~'5
function
in
this way, factorial can be defined by use
- (!A)
'+
!O
1.
quotation
of
all
argument
result
is
is
equal
mark ( , ) and
the
positive integers from
can
be
a positive numeric scalar,
the
same as
to
that
and
zero,
gamma (A-1):
the
of
but
the
period (.).
one
argument:
negative
to
c
If
the
argument
()
I'Jr
.:..
1.
3
,')
:I.
..
'-
B
B
!B
...
is
2
an array,
2pO
the
1
function
")
.....
:~
:1.
6
is
extended
to
each
of
the
elements:
59
Page 64
Dyadic (Two-Argument) Form: Binomial
The
binomial
that
can be
the
binomial expansion
vectors,
arguments
have
the
function
taken A at
or
other
is
a scalar or any single-element array. Arguments of
same shape result:
2
arrays.
!l+
result
a time.
of
the
The
is
the
The
th
8
argument
f.)
2!6
1 1::'
.,J
~5
!
()
0
()
!
:3
1
2!3
3
If
one argument
same as
of
that
the
multielement array:
of
is
the
a scalar
other
or
a single-element array,
argument.
A!B
number
result
power.
must
w
The
of
different
of
A! 8 is
The
arguments can be numeric scalars,
be
the
x
>-
..
....------
single
element
combinations
also
the
(A+l)
th
same shape, unless
the
y
Z !
........
J-----Argument
The combinations
argument 8
argument A(2)
the
shape of
is
applied
the
to
of
argumenf
coefficient
one
of
same shape
taken
result
is
the
every
element
B
of
the
B
of
at a time
'')
~5 ! ~5
:L
':N
0
1
~5
3
1
")
1
'+
0
1+
I.>
B~"2
:I,
:I,
I+!
3
.:-
2~)0
1 2 3
1+
B
o 1
2 3
:I.
I.)
4,
I
~5
to
10
1+
7Qx(P-l)!
10
2 !
"',+
~5
10
10
7,87~:j
If noninteger arguments are used, this
follows: Beta (P,Q)
is
equal
function
P+Q-l
relates
to
the
beta
function
as
60
Page 65
(
(
(
The?
Function: Roll
Monadic (One-Argument) Form: Roll ?8
The
roll
function
through
chance
other
8 (depending
of
being selected.
array.
The
('71
I~
result
on
shape
is a randomly
the
index origin). Each integer in
The
argument
of
the
result
7300
202
?:30
()
3
?~5
7 9
2
:I.
4·
'?6
6
1.1·
!5
6
76
6
6
If
the
argument
is
an
array,
the
function
selected integer
can be a positive integral scalar, vector,
is
the
same as
is
extended
from 0 through
the
that
of
the
to
each
element
range has an equal
argument:
of
8-1
the
or
1
array:
or
(~
('
B~2
B
1.:1.
2~?
33
",.1+
!7.i
!:5
6
t')
?B
2
:l7
:1.6
21+
:I.~~
,+
Dyadic (Two-Argument)
See
the
Deal
function
3pl1
Form
later
22
in
this
33
chapter
~4
under
55
66
Primitive Mixed Functions.
c
61
Page 66
The A Function: And
Monadic (One-Argument) Form
is
There
Dyadic (Two-Argument) Form: And A/\ B
The
value
or
is
shape result:
no monadic form.
and function result
of
the
arguments must be either 0
other
arrays.
a scalar
or
any
CD
is
1 when A and B are
The
arguments must be
single-element array. Arguments
both
1; otherwise,
or
1.
The
arguments can be scalars, vectors,
the
same shape unless one
of
the
the
result
of
the
same shape have
is
O.
The
arguments
the
same
0
:1.
0
()
()
0
If
one
argument
same as
of
that
the
multielement array:
0
:1.
:I.
0
0
:J.
:1.
0
01\
:1.1\:1.
1AO
0
:I.
of
the
Bf·2
B
j.AB
:1.
0
is
a scalar
other
2pO
Operator
:tAO
:1.
1.
0
:I.
or
a single-element array,
argument. The single element
1-
1 0
the
And Table
'---
shape
of
is
applied
o
Argument B
the
result
to
every element
-Argument A
is
the
Page 67
The v Function: Or
GJ
(:
Monadic (One-Argument) Form
There
is
no monadic form.
Dyadic (Two-Argument) Form: Or A v B
The
or
function result
result
is
O.
The values
scalars, vectors,
one
of
the
arguments
same shape have
is
a 1 when either
of
the
or
other
arrays.
is
a scalar
the
same shape result:
arguments must be 1 or
The
or
any single-element array. Arguments
1vO
OvO
o
o
0 1
1vO
1 0 1
o 1 1 1
or
both
arguments are 1; otherwise,
O.
arguments must be
Operator
'"
The
arguments can be
the
same shape, unless
Or Table
v
the
of
the
......
I----Argument
A
c
C/
c
one
argument
If
same
as
that
of
the
multielement array:
0 1
()
1
j. j.
:1.
1
is
a scalar
of
the
other
B~··2
2pO
B
lvB
or
a single-element array,
argument. The single element
j.
0 1
the
shape
is
applied
of
the
to
result
is
the
every element
63
Page 68
The'"
Function:
Not
GJ
Monadic (One-Argument) Form:
The
not function result
ment must be 1
of
the
result
is
or
the
O.
The
same
is
as
1
o
If
the
argument
1 0
0
0
1
()
1
()
1 0
is
B~"2
H
1
NB
1
an array,
3(.>0
Not
'"
B
1 when B
argument can be a scalar, vector,
that
the
is
0 and 0 when B
of
the
argument:
function
is
extended
is
1.
to
each element
1
The
or
values of
other
array.
of
the
the
The
array:
argu-
shape
Dyadic (Two-Argument) Form
There
is
no dyadic form.
64
"'
..
Page 69
The
A Function: Nand
OJ
CD
(
c
The A symbol
Monadic (One-Argument) Form
There
is
Dyadic (Two-Argument) Form: Nand
The
nand function result
The values
other
arrays. The arguments must be
is
a scalar
shape result:
is
formed by overstriking
no monadic form.
is
0 when
of
the
arguments must 1
or
any single-element array. Arguments of
O~l
1
o
o
0 1
1XO
:I. 1 :I.
0
:I.
the
AAB
both
A and
or
O.
The arguments can be scalars, vectors,
the
same shape, unless
0 1
and
Bare
(/\)
and
1;
otherwise,
the
same shape have
Nand Table
the
not
one
(,...,)
symbols.
the
result
of
the
arguments
.----Argument
the
is
1.
same
or
A
c
If one argument
same
as
that
of
of
the
multielement array:
B~"2
B
0
:I.
1
0
1XB
:I.
0
0
1.
is
the
a scalar
2pO
or
a single-element array,
other
argument. The single elemeht
:L
the
shape
is
applied
of
the
to
result
is
the
every element
65
Page 70
The V Function:
The
v symbol
Monadic (One-Argument) Form
There
is
Nor
IT)
is
formed
no monadic form.
OJ
by
overstriking
the
or
(v)
and
the
not(rv)
symbols.
/'
"
Dyadic (Two-Argument) Form:
The
nor
function result
values
of
the
arguments
other
arrays.
is
a scalar
shape result:
The
arguments
or
any single-element array. Arguments
o
O\jO
1
o
()
:1.
:I.
0 0 0
If
one
argument
same as
of
that
the
multielement array:
of
is
the
a scalar
other
Nor
A
vB
is 1 when
must
:l(JO
argument.
A and B are
be 1
or
O.
must
be
the
:1.
0
1.
or
a single-element array,
The
both
0; otherwise,
The
arguments can be scalars, vectors,
same shape, unless
of
the
same shape have
the
shape
single element
is
the
one
of
Nor Table
of
the
applied
to
the
result
arguments
the
~---
result
every
element
is
is
O.
or
same
the
The
Argument
A
66
0
0
:I.
:1.
1
1
0
0
B~M2
B
OC:B
2?>O
1
Page 71
The >Function: Greater Than [I)
Monadic (One-Argument) Form
is
no
There
monadic form.
(
(
Dyadic (Two-Argument) Form: Greater Than
The greater than function result
otherwise the result
arrays. The arguments must
scalar or any single-element array. Arguments of the same shape
shape result:
is
O.
is
The arguments can
be
the same shape, unless one of the arguments
A>B
1 when argument A
be
numeric scalars, vectors, or other
o
-'2>
0
o
.-
~.~
;:
....
~~
o
1
o
'-:1.
5,1
o o 1
If
one argument
same
as
tha,t
of the multielement array:
is
a scalar or a single-element array, the shape of the result
of the other argument. The
'-~3>~5,
1
single
o
'''1·1·
element
is
greater than argument
have
the same
is
applied
to
every element
B;
is
a
is
the
('~,
ll,
/
e
2
1+
~3
OCT
system variable).
~5
(.>
B~"2
.f.{
-x
••
c'
..
}
1
0 0
1
6
3>B
0
1 2
I~.
1
0
Note: The result of the > function depends on the
Chapter 5 for information on the
:1.
1'-
,'J
t.)
OCT
system variable
(see
67
Page 72
The = Function: Equal To
Monadic (One-Argument) Form
There
is
no
monadic form.
Dyadic (Two-Argument) Form: Equal To A=B
[J
The equal to function result
of argument
can be scalars, vectors, or other arrays. The arguments must be the same shape,
unless one of the arguments
of the
same
B;
otherwise, the result
shape
have
is
1 when the value of argument A equals the value
is
O.
The arguments (numeric or character)
is
a scalar or any single-element array. Arguments
the same shape result:
0::::5
()
1,65~321=1,65~321
1
1::::
I A I
o
.'
A
I::::
'B'
o
':1.
':::::1.
o
:I.
o
o 0
If
one argument
same
as
that of the other argument. The single element
of the multielement array.
is
a scalar or a single-element array, the shape of the result
is
applied to every element
is
the
68
'A':'ABACADAEAFAG'
101
Note:
OCT
system variable (see Chapter 5 for information on the
0
101
If
the arguments are numeric, the result of the = function depends on the
0 1 0 1 0
OCT
system variable).
Page 73
(--
The < Function:
Monadic (One-Argument) Form
is
There
Less
Than
no monadic form.
CD
Dyadic (Two-Argument) Form:
The
less
than
function result
wise
the
result
is
O.
The arguments can be numeric scalars, vectors,
-'+
.
the
'+
The arguments must be
any single-element array. Arguments
:L
.65<2
1
:I.
:I.
0-::
o
:I
.•
12~5<:I
o
5.1
o 1 0
If
one
argument
same
as
that
of
the
multielement array:
of
is
the
a scalar
other
Less
Than A < B
is
1 when argument A
same shape, unless one
of
the
.•
:1.23
or
a single-element array,
argument. The single element
is
of
same shape have
the
less
than
the
arguments
shape
is
applied
argument
the
same shape result:
of
the
to
or
other
is
a scalar
result
every
8;
other-
arrays.
or
is
the
element
('
('
c
3p:L
f.u"2
B
I")
1
3
-:"
c'
l~
..J 6
~5<B
()
0
0
:L
1
:L
B<3
:L
l.
0
()
0
0
Note:
The
result
of
the
< function depends
Chapter 5 for information
~'5
~!
on
the
5 6
'+
OCT system variable).
on
the
OCT system variable (see
69
Page 74
The
~
Function: Greater Than
or
Equal
To
[~)
Monadic (One-Argument) Form
There
is
no monadic form.
Dyadic (Two-Argument) Form: Greater Than
The
greater
or
equal
scalars, vectors,
of
the
shape have
than
to
argument
arguments
the
same shape result:
1
or equal
B;
or
other
is
a scalar
65;::2
.
to
function result
otherwise,
arrays.
or
the
The
arguments must be
any single-element array. Arguments
0
"'2;::0
(I
:~~
;::
~~
1
~5
.
1.
:I.
1
If
one
same as
of
the
argument
0
0
is
a scalar
that
of
the
other
multielement array:
or
a single-element array,
argument.
The
or
Equal To
is
1 when argument A
result
is
O.
The
single element
A~
B
is
greater
arguments can be numeric
the
same shape, unless
of
the
the
shape
of
the
result
is
applied
to
every element
than
same
is
the
l_;,
one
1
1+
:1.
()
Note:
5
for
Bf'2
B
'')
.:.,
3
!7j
6
3~:B
1 1
0
0
The
result of
information
3
I.f.
1::'
..J
;!.
3pl
the ~ function depends
on
the
OCT system variable).
6
on
the
OCT system variable (see Chapter
70
Page 75
(
The,;
Monadic (One-Argument) Form
Function:
There
is
Less
no
monadic form.
Than
or
Equal
To
[~
)
Dyadic (Two-Argument) Form:
The less than
to
argument
vectors, or other arrays. The arguments must
arguments
have
the same shape result:
or
equal to function result
B;
otherwise, the result
is
a scalar or any single-element array. Arguments of the same shape
Less
:I.
:I.
:I.
-::···"
.,.
JIO..
0
o
5.1-
o 0
1
If
one argument
as
same
of the multielement array:
that of the other argument. The
is
a scalar or a single-element array, the shape of the result
Than
or
Equal To
is
1 when argument A
is
O.
The arguments can be numeric scalars,
single
A~
B
is
less
be
the same shape, unless one of the
element
is
applied to every element
than or equal
is
the
c
--"'
r.{~~·2
3p:J.
13
1
2 3
I.~
5 6
3~;B
0
0
1
:I.
1
1.
Note: The result of the
5 for information on the
2
~
function depends on the
OCT
system variable).
~5
I.)
ll·
:3
OCT
system variable
(see
Chapter
71
Page 76
The F Function:
Monadic (One-Argument) Form
There
is
Not
Equal To
no monadic form.
CD
Dyadic (Two-Argument) Form:
The
not
equal to function result
otherwise, the result
vectors, or other arrays. The arguments must be
arguments
have
is
a scalar or any single-element array. Arguments
the
same shape result:
Not
Equal
is
is
O.
The arguments (numeric or character) can be scalars,
Ot-5
1
o
'A't-'A'
()
:I.
"':l
···:3t-~.:;,:I.
argument.
o 1
If
one
argument
same
as
that
of
the
multielement array:
~5
,
:I.
:1.
is
a scalar or a single element array, the shape of
of
the
other
To
A'/=B
1 when argument A
the
same shape unless one of
()
'"4·
The
single element
is
not
is
equal
of
the same shape
the
applied
to
argument
result
is
to
every element
8;
the
the
72
'A'¢'ABACADAEAFAG'
o
:I. 0 :I. 0 :I.
Note:
If
the arguments are numeric, the result of the
OCT system variable (see Chapter 5 for information on
The
not
equal to function can also be used
in
this manner,
the
Operator~---
0
value of
:I.
0 1 0
the
arguments must be either 0
Exclusive Or Table
:I.
as
an exclusive or function. When used
_Argument
~function
the
depends on the
OCT system variable).
or
1:
A
Page 77
73
Page 78
Dyadic
Mixed
Functions
AlB
or
A/[I]
B or
AlB
Name Result
Compress
The elements from B
to
the
1's
in
A.
that
correspond
."
..
J
A\B
or
A
\[lJ B or
A~B
AtB
Ai-B
AlB
A¢B
or
A¢[I]
B by
orAsB
A~B
A?B Deal The
Expand
Take The number
Drop
Index
of
Rotate
General ized
transpose specified
is
B
by A; 1
B;
are
The
are dropped from
The first occurrence
in
The elements
are rotated
the
The
are randomly selected from
selecting
expanded
in
A inserts an
a 0
in
A inserts a 0
taken
from
number
B.
A.
If A is
elements
coordinates
by
number
the
to
the
format
of
elements specified by A
B.
of
elements specified
B.
in A of
of
B are rotated as specified
positive,
to
the
left.
of
B are
of
B interchanged as
A.
of
elements specified by A
same
number
specified
element
or
blank element.
the
the
elements
If A is
rotated
to
B,
twice.
from
by
A
elements
of
negative,
the
right.
without
B
74
A.LB
ATB
AEB
AffiB
AlB
Decode The value
(base value)
Encode The representation
( representation)
Membership A 1 for each
Matrix Solution
divide equations with coefficient matrix
Format
the
argument A.
the
argument
found
not
(matrices) B and right-hand sides A
the
more sets
Argument B converted
array in
argument
of
argument B expressed
number
number system specified by
found.
least squares solution
system specified by
of
A.
element
in
B and a 0 for each
to
one
or
more sets
of
linear equations.
the
format
A.
specified
argument B in
of A that
element
of
to
one
to
a character
by
can be
linear
in
or
or
"I
Page 79
Note:
The
mixed functions
(see
Operators
coordinate
coordinate
index
entry
coordinate
index value
row
coordinate
is
not
specified,
overstruck with
assumed (unless an index value was also used). When a
plied
to
ments
in
later
in
of
an array. This
to
which
can be
from 1 to
(first coordinate) has an index value
of
2, and so on. A matrix, for example, has an index value
and an index value
the
last
the
function
a specific coordinate,
the
specified
reverse,
this chapter) reduction and
the
mixed
coordinate
coordinate.
is
done
function
the
number
of
symbol
the
operation
rotate,
(columns)
For
compress,
by
using an index
or
operator
of
coordinates
2 for
the
or
operator
takes
example; assume
scan
is
of
1,
column
is
assumed. If a - (minus) symbol
symbol,
place
and
expand,
can be applied
entry
[I] which indicates
applied.
the
coordinate.
function
between
The
in
the
array;
next
coordinate
the
first
you
have a 3-rank array:
and
the
operators
to
a specific
value
of
the
the
leftmost
has an
of
.1
for
the
If an index
coordinate
or
operator
corresponding ele-
is
entry
is
ap-
the
is
(~
('
• When
• When
• When
The p Function:
Monadic (One-Argument) Form:
The
coordinate
argument
the
first coordinate (planes)
corresponding elements
the
second
the
corresponding elements
the
third
tween
the
shape
function
of
can be any variable
coordinate
coordinate
corresponding elements
Shape,
the
(J • ABeD ·
Reshape
result
argument, which indicates
1+
"'1
A-
••
(,J
:l
2
pl.
2 3
~3
A~"2
A
3
2
1
c·
l~
6
\J
pA
3
2
in
each plane.
(rows)
in
each row per plane.
(columns)
(Structure)
Shape
p B
is
the
shape
or
constant:
....
1-------
is
specified, the
is
specified,
is
specified,
in
each column
of
the
argument; it has
the
A Vector with
operation
the
the
per
length
operation
operation
plane.
one
of
that
Four
takes
place
between
takes place between
takes
place be-
element
coordinate.
Elements
for each
The
('
The
shape
function
coordinates. An
p2
p'T'~
applied
empty
to
a scalar yields an
vector
is
indicated
Blank Result Lines
empty
vector, since a scalar has no
by
a blank result line:
75
Page 80
The instruction p p B yields the rank (shape of the shape, or, number of coordinates)
B:
of
B~2
2 3p'CARBARFARARE'
B
CAR
BAR
FAR
AI~E
pH
2
2
~5
ppB
:1
Dyadic (Two-Argument) Form:
The
reshape
element(s) from argument
array
array, the elements are repeated.
are required to
Argument A must
number
rank, of the result. Argument B can
elements of argument A are nonzero, then B cannot
in
row
of
elements
function forms
order.
fill
the array, only the required number of elements are used.
be
Reshape
an
B.
If
there are not enough elements
a nonnegative integer or vector of nonnegative integers. The
in
argument A
(Structure) A p B
array of the shape specified
The elements of argument B are placed into the
If
there are more elements
is
equal to the number of coordinates, or the
be
2
:3
1
2
5 6
4·
2p'ABCDEFGH'
4·
AB
en
EF
GH
5(.)
• MOUSETRAP'
MOUSE
p
3
l+
:l.23
:1.2:3
1.23
123
123
:1.
23
12~5
:1.
2:'~
:I.
:~3
1,23
:1.23
1~~:3
12~5
A~~
2p1
2 3 ~ 5 6 7 8
A
1 2
3
4-
5 6
'7
B
by
argument A
in
argument B
in
any variable or constant.
be
an
empty array:
using
to
fill
the
argument B than
If
all
of the
76
1.
2 3
I.~
!7i
6
6p·
..
•
Page 81
(
The,
Function: Ravel, Catenate, Laminate
Monadic (One-Argument) Form: Ravel
The
ravel
function results in a vector containing
argument B
in
row order. Argument B can be a scalar, vector, or
vector contains
1 2
~3
1+
is
an array,
the
A~2
A
the
elements
same number
2
2pl
5 6
'7
8
IA
:1.23'+5678
B~"2
:3
p • ABCDEF ·
B
ABC
DEF
IB
ABCDEF
o
,8
the
elements
in
the
vector are taken from argument B
other
of
elements as argument
2 3 ~ 5 6 7 8
of
argument
array. The resulting
B:
B.
If
(
c
Dyadic (Two-Argument) Form: Catenate
The function
when
the
is
catenate when
[I] entry
is
a fraction.
the
or
[I]
Laminate
entry
(index entry)
A,
[I]
8
is
an integer and laminate
77
Page 82
Catenate (The Index [I]
an existing coordinate. (See
to
join
two
items along a new coordinate). The index
coordinate
array. If no index [I]
sizes can be joined, providing
same (see Catenation
is
expanded.
A~:I.
[u··7
AlB
-,
L~
1
9
A+-2
B+-2
A
3
1 2
5 6
'+
B
7
8
10
:L
1.
:1.2
AlB
2
1
L~
5
AI[1JB
1
2
L~
5
7
8 9
1.0
11.
:1.2
A,
,.)
1
.:-
.::'
4
\.I
A}[~.~]10
')
t:_
:1.
I'"
I.f-
,,)
10
:1.
0
20
30
I')
1
1:-
5
'+
Entry
1+
9
5
3p1
3p7
9
~3
10
6
:3
6
[2Jf.t
3
10
6
~5
10
6
20
20
:3
6
Is
an Integer):
the
The
is
specified,
in
Chapter 3):
~5
I)
t:"
8
7
8
II
..,
8
1:1.
20
30
..
The
catenate function joins
laminate function following
index
entry
must be a positive scalar
the
last coordinate
the
lengths
of
the
coordinate
1::'
t)
,.1
3 4
12
1.0
11.
9
9
12
9
1
r)
~-
C:I.JA
two
for
a description
[I],
if given, specifies which
or
one-element
is
used. Matrices
not
specified are
items along
of
of
unequal
the
how
/
,1
"~",
78
Page 83
Laminate (The Index [I] Entry
creating a new coordinate, specified by
If
tive fraction.
the
first coordinate; if
placed between existing coordinates 1 and 2 (the new coordinate
ways has a value (or length)
new coordinate
3 matrices are laminated:
the
in
is
a Fraction):
index
entry
the
index
of
the
shape vector (see
The
the
is
between 0 and 1,
entry
is
between 1 and 2, the new
2).
The
following chart shows
the
laminate function joins
index
entry
following examples) when
two
[I] which must be a posi-
the
new coordinate becomes
coordinate
that
is
the
positions
two
items by
added
of
3 by
is
al-
a
Index Value
.1
- .9
1.1
- 1.9
2.1 - 2.9
Lamination requires either
of
the
arguments
:I.
2 3
'+
~.:;
7 B
:I.
1.
'+
'+
77
:1.
LI·
is
a scalar:
A~3
B~3
I~
6,
9~
B
22
:3:~
~::; ~.:;
66
B8 ,99
C~"A}
.,
r
2 3
~5
I.>
3pl
3pl1
I:
I 8:1B
7 B 9
Positions
Coordinate
Vector
that
arguments A and B are
of
3
3 3
New
in
3 3
2 3 4 5 6 7 8 9
22
33
~~
55
the
Shape
3
the
same shape
66 77
88
99
or
that
one
c
c
2
1.1
'4·4
77
3
22
1.':'1::'
\."J
B8
:3
(o)e
•
3:3
66
99
Shape Vector
79
Page 84
1.
:1.:1.
7
."'''.'"1
( (
2
~3
3
C~··i~
C
2
:~
22
~5~5
B
<.»(.»
BB
(.)C
II
-----------Shape
~5
Cf-A,
...
r-
:I.
:I.
1.
,.)
r)
.-:'.A
..
2
··X
,:>
~3:~
I.f.
I+I.~
5~:.i
~5
6
c>6
77
7
BB
8
99
9
pC
,.)
II
k
3
}
I::
:1
..
~::.i:l
B
/
"'
9
Vector
[2.
:I.:lB
Shape Vector
The following examples show the result when the two matrices
are catenated instead of laminated:
AI[lJB
1.
2
:5
1+
5
6
"7
8
9
:1.:1.
22
~53
1::'1::.
.J
•.
1
4-
"7
J
B8
A,[2JB
,.)
.:..
1:,"
.. I
8 9
66
99
:3
6
1
:1.
22
.::
.
.::.
I.I·I~
.
•• J ...
J
77
BB
33
66
99
4·4-
77
in
the preceding example
80
Page 85
The I Function: Compress
CD
(
(
Monadic (One-Argument)
See Reduction later
Dyadic (Two-Argument) Form: Compress
The
compress function selects
to
1 's in
argument
values 0
must have
• One
•
When
the
(columns)
rank
or
1.
the
of
the
Argument B is
A
must
be
argument B is
coordinate
is
assumed. If
of
the
result
")
.....
1
3
Forra
in
this
chapter
elements
A.
Argument A must
Argument
same
arguments
the
that
:I.
()
B can be any scalar, vector,
number
a multidimensional array;
same as
a multidimensional array,
is
is
the
0
:1.
(}
of
elements unless:
is
a scalar
the
length
acted on. If
the
AJ.B
same as
()
:l./l
2
")
OIl
..:..
the
~:~
:3
or
the
form
under
APL
Operators
A/Ul B or
from
be a logical scalar
single-element array.
of
the
index
is
rank of argument
2
AlB
argument B corresponding in sequence
then
the
argument B
the
[I] index
entry
is
used,
the
first
I.J.
..
or
AfB
or
or
other
number
coordinate
omitted,
coordinate
B:
/Blank
vector
having
the
array. Both arguments
of
elements
entry
the
in
being
acted
is
used
to
last
coordinate
is
assumed. The
argument
on.
specify
Display Line (empty array)
(".
e
C~'
1
c'
·_1
9
1.
<"i
2 3
6
:1.
0
:l
9 10
2
6
10
:I.
!5
9
")
.:-
(~)
j.O
...
)
..:..
10
"7
11.
t·)
.:-
:5
"7
11
2 3
I.)
10
[H<5
B
:3
"7
11
:I.
0
:5
j.l
0 1
0
1
3
11
0 1 1
liB
'7
:I.
:1.
OIB
I.J.
f>:I.
2
I.J.
B
:1.
:~
:l./[:I.::tB
I.J.
\
j
':>
.....
O/r:2::tB
:1.
\
liB
4·
j
')
......
O/S
4·
8
1
':>
....
:3
I.J.
,::-
,.J
I.>
"7
10
B 9
The
the
argument
The
the
argument
Blank Display Line
:I.
II
first
coordinate
first
and
A, are selected .
second
second
A, are selected.
::.~
(rows)
third
rows, as specified by
coordinate
and
third
columns, as specified
(empty
is
specified;
(columns)
array)
is
specified;
by
81
Page 86
The \ Function: Expand
Monadic (One-Argument) Form
CD
~I.
J
See Scan later
Dyadic (Two-Argument) Form: Expand A
The
result of
argument
in
this
the
expand function
A.
Each 1 in
chapter
argument
under
is
A selects an
APL
o in argument A inserts a 0 (or blank
must be a logical scalar
scalar, vector,
same number
a multidimensional array, argument A must have
length
When argument B
that
is
assumed. If
If
argument B
the
number
array,
the
or
of
of
the argument B
acted on.
the
is
of
1's
rank
of
1.
")
.:..
3
0
1
B~"2
B
3
1.
2
1:."
1+
.J
6
t
"y
,:)
:L
~~
()
0
0
5 b
4·
l 1
")
3
0
.:..
1
c:-
I.~
O 6
.J
1
")
1
It:
••
3
{}
0 0
6
4-
5
other
1's as
is
an array,
If
the
A~B
is
a scalar
in
argument
the
result
:1.
0
0
3~)1
{}
l\[lJB
0
l\.B
0
or
vector having
array.
If
argument B
the
number
coordinate
index
used,
or
1
of
the
[I]
entry
is
then
the
single-element array, it
A.
If argument B
is
the
same
")
I:'.
0\1
I")
.,.
...
4-
3
\
1\[2JB
'\
Operators.
\[1]
B
or A \B
argument B expanded as indicated by
for
character data)
the
values 0
is
elements
being acted on.
index
entry
omitted,
first coordinate
as
the
or
A~B
element
a vector, argument A
the
rank
from argument B and each
in
the
result. Argument A
or
1. Argument B can be any
in
argument
the
is
used
last
is
is
not
of
B.
same
number
to
specify
coordinate
is
assumed.
extended
a scalar
the
B argument.
If argument B
to
or
must
of
1's as
the
coordinate
(columns)
a length equal
single-element
3
5 6
The first coordinate (rows)
expanded; a row
tween
the
first and second row.
The second coordinate (columns)
expanded; a column
between
the
second and third columns.
have
the
is
the
is
to
is
inserted be-
is
inserted
is
is
82
Page 87
The
4>
Function: Grade Up
The
~symbol
OJ
is
formed by overstriking
OJ
the
11
symbol and
the
I symbol.
Monadic (One-Argument) Form: Grade Up
The
grade up function result
argument B in ascending order.
of
the
smallest
smallest element in argument
When
two
tion
in
the
occurrence appears first in
same as
"~)
.....
'+
element
or more elements
yector determines
the
number
1
.$3
C'
.J
of
1-
3
4tAt-6
-5
6
2
4-
ib:3
L~
:I.
6
The
following example shows
tor
into ascending order:
At-:l.~
A
11
12
1~
3
1
3
6
r>
5
.:-
[¢.AJ
15
is
in
argument
in
their
the
elements
I!!'
...
1 2
~5
2
:I.
:~
12
16
16
the
index values
That
B,
and so on. Argument B must be a numeric vector.
the
vector have
order
output).
in
the
I.f.
1+
:I.
::!
~5
how
the
18
:1.8
~B
that
would select
is,
the
first element
B,
the
next
element
the
in
the
result (the index value
The
number
argument:
:~
grade up function can be used
15
1:1.
of
the
is
the
index
same numeric value,
of
elements
the
result
in
the
elements
is
the
of
the
next
their
of
the
result
to
sort
of
index
posi-
first
is
the
a vec-
The result
because
for an example
Note:
ter 5 for
Dyadic (Two-Argument) Form
There
of
the
of
the
The
result
information
is
no
dyadic
grade up function
way equal elements are handled; see
uSing
the
of
the ~ function depends
on
form.
is
not
the
reverse
of
the
grade down function
The
'W
Function: Grade Down
grade up and grade down functions with equal elements.
on
the
the
010 system variable).
010 system variable (see
Chap~
83
Page 88
The
'I'
Function:
The
1 symbol
Monadic (One-Argument) Form: Grade Down 1
The
grade down
of
the
numeric vector
of
the
result
the
index
be
a numeric vector. When
numeric value,
index value of
elements
~)
3
:5
:1.
5
2
in
of
the
1
5
:1.
Grade
is
is
the
the
their
the
~:'5
Lf.
\f1Af'6
6 2
~:3
~5
Down
formed
function
of
index
next
largest
position in
first occurrence appears first
result
is
the
~:)
:I.
11
"M
"
......
4·
:3
6
LI·
6
(]]
by overstriking
result
Js
the
argument 8 in
of
the
largest
element
two
or
the
same
as
I')
1+
,.-..
1+
:l
5
1::'
,J
2
1-
CIJ
the
index values
descending order.
element
in
argument
more elements
vector determines
the
number
:3
Vsymbol and
that
would
in
argument
8,
and
in
the
their
in
the
output).
of
elements in
the
I symbol.
select
the
elements
That
is,
the
first
8,
the
next
element
so on. Argument 8
vector have
order
in
The
the
argument:
the
same
the
result (the
number
element
is
must
of
The
following example shows
vector in descending order:
A~14
f~d::
18
16
15
The following example shows
up
and
grade
down
A~M!:;
A
r)
c'
...
1
7 3
A
••
B
12 16
~A:I
1Lf.
12
functions:
")
A.. 8
LI·
:1.0
,A
1+
1 6
3
7
B
6 1
how
the
grade
down
function
18
15
11
11
how
equal elements are handled when using
:5
7
:I.
1+
:5
2
If
:3-
8
:~
7
10
2
1
Positions 2
and
can be used
9 and 5
to
and
sort
the
10
grade
a
are equal.
84
Page 89
(
Because
first)
not
the indices
for
both the grade down
the
reverse
of
the grade up function:
for
the equal elements
A[,A:J
10
8 7 5
1 2 2 3 3 4 5 7 8
~
3 3 2 2 1
A[~AJ
and
are
in the
same
grade
up function, the grade down
10
order
(first
occurrence
function
is
(
Note: The result
for
ter 5
Dyadic (Two-Argument)
There
information on the 010 system variable).
is
no dyadic form.
of
the f function depends on the
Form
010
system variable
(see
Chap-
"
c
c
85
Page 90
The + Function: Take
Monadic (One-Argument) Form
There
is
no monadic form.
CIJ
Dyadic (Two-Argument) Form: Take
The
take function result
from
argument
must be a scalar
be
a scalar. Argument A must be a vector with an
of
argument
are
taken;
A specifies more elements
is
padded with
value
of
B.
or
B.
When argument A
when argument A
O's
A:
:~
"':~t:l,
7t:l.
t
23'+5
"'7tt
00
1
:~34,5
B~3
is
the
Argument B can be a scalar, vector,
vector
of
integers.
is
than
(or blanks for character data). The shape
2
2 3
I",
00
2 3
'+
~pl
2 3 ~ 5 6 7 8 9
B
'")
:I.
!:5
5
9
:1,
'1
.:..
6
A"
6
10
3
'7
~5
"1
1.1
2
~5tB
'+
8
:1.2
At
8
number
is
positive,
negative,
the
number
~3
5
of
elements specified
If
argument B
the
last elements are taken.
of
is
element
the
first elements
elements
by
argument
or
other
array. Argument A
a vector, argument A must
for each coordinate
of
argument B
in
argument
of
the
10 11
If
argument
B,
result
12
A, taken
the
result
is
the
86
1-
'.~
7
10
1
1
7
1
2
5
'+
"1
1.0
1t
2
5
B
1:1,
3
6
8
Bf-2
B
3
6
9
:l2
1
1
")
.:..
1 2
"'1
9
:1,2
1-
,')
.:..
:L
1tB
3tB
2
3~)
tB
3tB
1.
2 3 4 5 6 7 8 9 10
:1.1
12
Page 91
The + Function: Drop
Monadic (One-Argument) Form
There
is
no monadic form.
OJ
(~"
Dyadic (Two-Argument) Form:
The
drop function result
of
elements specified
other
array. Argument A must be a scalar if argument B
When argument B
nate
of
argument
are dropped from
dropped:
by
is
an array, argument A must have
B.
When argument A
the
result; when argument A
3J.l. 2 3
B~3
~p1
B
1+
:5
2
1
1::-
...
9
7
1l.
1
5
1 6
2
6
10
f.)
12
7
11 1
2.J.B
1
--1
a
~~
-2.J.B
Drop
A+B
is
the
remaining elements
argument A
is
dropped. Argument B can
is
positive,
of
the
is
negative,
argument
is
one
element
first elements
2 3 ~ 5 6 7 8 9 10 11
B after
be
a vector
a vector.
for
each coordi-
of
the
last elements are
12
the
number
or
argument
B
c
c
87
Page 92
The 1 Function: Index Generator, Index
of
OJ
Monadic (One-Argument) Form: Index Generator
The index generator function result
ing
with the index origin (see
be a nonnegative integer
that
is
a vector containing
010
system variable
is
either a scalar
\5
1.
2 3
Lf.
5
A~"
\ 6
A
12~3Lf.56
~:i
+
,5
..--
Each
of
the
generated integers
6 7 B 9 lO
Dyadic (Two-Argument) Form: Index
The
index
of
function result
the
element(s) in argument
a scalar, vector, or array. The result
in
argument B
is
ment
cannot
one greater than
be found
the
of
A 1 8
is
the index
B.
Argument A must be a vector. Argument B can be
in
largest index of A (010 + pA):
of
is
the same shape as argument
argument
18
the
in
Chapter 5). The argument can
or
a single-element array.
the
first occurrence
A,
the value
of
first B integers, start-
is
added
to
5.
in
argument A
B.
If
the
element
the
index for
that
of
ele-
2
.....
41-----------------
'ABCDEFG','C'
3
2
6
1 9
1
9
9
Note: The result of the 1 function depends on
5 for information on
8
1')
c·
\.J
.:..
:~
:1.
9 2
A
...
1
:I.
A\22
")
.:..
A."9
3pl
B~"2
B
A\S
22
:33
Lf.LI·
t)
B 2
8
9 8
1
the
010 system variable).
5~5
Lf.
B
C'
,J
2
Second Element
the
010
system variable (see Chapter
88
Page 93
The
4>
Function: Reverse, Rotate
OJ
m
("
(
(
The ¢ symbol
form
of
symbol.
Monadic (One-Argument) Form: Reverse
The
reverse
expression.
is
formed by overstriking
the
function symbol
function reverses
is
9,
formed by overstriking
the
elements
<p
the
[I]
B
of
0 symbol and
or
<f>;B
or
aB
argument
B.
the
I symbol. A special
the
0 symbol and
Argument B can be
the
-
any
89
Page 94
When argument B
specify the coordinate
ordinate (columns)
is
acted on:
I.J. 3 2 1
is
a multidimensional array, the index entry [I] can be used
is
<1>1
2 3
<I>'I...IVE'
EVIL
~5
2 1
f.)
5
I~.
A~2
A
SAVE
MUCH
M()I~E
TIME
(~r::I.]A
MORE
TIME
SAVE
"
MUCH
(J>[2::tA
MUCH
BAVE
TIME
"
MORE
(~[3]A
EVAS
HCUM
\
EROM
Et1IT
(DA
EVAS
HCUM
that
is
acted on.
acted on.
2
'--------The
~-----The
~-----The
If
the
1+
I+p
'SAVEMUCHMORETIME'
If
the index entry
sB
form
is
used, then the first coordinate
first coordinate (plane)
the planes are reversed.
second coordinate (rows)
the rows
specified; the columns
reversed.
The last coordinate
in
each plane are reversed.
third coordinate (columns)
is
is
omitted, the last co-
is
specified;
is
specified;
is
in
each plane are
acted on.
to
90
EROM
EMIT
MORE
TIME
SAVE
MUCH
"
sA
"
'-------The
first coordinate
is
acted on.
Page 95
Dyadic (Two-Argument) Form: Rotate A
<1>
[I]
Bar
A<1>B
or
AsB
(
(
c
The rotate function rotates the elements
specified by argument
argument B are rotated
the
elements are rotated
can be any expression. The shape
When argument B
specify the coordinate
ordinate (column)
is
acted on.
If
argument B
If argument-B
argument A
the
number
by 4 matrix (each row has four elements) and
must have four elements:
3
4·
4-
5
31+~5:1.2
is
is
is
a vector, the number
of
elements
2<1>:1.
5
'!2:1
:I.
2 3
'7(~:I.
B~3
A.
If
argument A
to
the left (rows), or upward (columns). If A
to
the
right (rows), or downward (columns). Argument B
is
a multidimensional array, the index entry
that
is
acted on. If the index entry
is
acted on. If the
a vector, then argument A must be a scalar
a matrix, then argument A must be a scalar
in
the coordinate being rotated. For example, if B
2 3
4·
5..--
2 3
I.J.
5
2 3
I.~
5
4-p
1 2 3 ~ 5 6
B
:I.
2
:5
56'7
9
:1.0
52'7
9 6
1.
10
:I.
6
11
:1.2
:I.
6
:1.:1.
12
527
9
1 10 3
-1.
()
9
:I.
5
1.
1
o
2
"7
o
2 3
"7
:t.
6:1.1
A~"~"1
f~
"':1.
A(~[1]B
2 1.l B
6
0
1+
8
:1.1
()
~:
2$r.1JB
1.1
~
3
2<1>[2:1B
:I.
:3
I.~
\
!7j
B
9
:1.0
2<J)B
:I.
5
L~'
B
9
:1.0
1
2eB
0
12
\"-----The
LI·
S
01.2
-2
3
12
'7
L~
i
'-------The
'------The
of
is
positive, then the elements
of
the
result
AsB
form
of
elements
(2--1~
The first coordinate (rows)
therefore, the rotation
therefore, the rotation
argument B the number
is
the same as
is
omitted, the last co-
is
used,
then
or
or
in
argument A must be
the
row coordinate
3 4 5
'7
8 9
10
r:: r 1
J
second coordinate (columns)
last coordinate
first coordinate
lOJJ
is
of
is
that
of
argument
[I]
can be used
the first coordinate
single-element array.
vector. When
is
specified, A
11
:1.2
is
is
between rows.
[:2
is
between columns.
acted on.
is
acted on.
positions
of
negative,
the
same
is
a 3
specified;
is
specified;
B.
to
as
91
Page 96
If
argument B is
rank
that
be
the
same as argument B less
B~":5
~~
an N-rank array, argument A
is
one less
~3
p \
27
B
"1.
...
2
I!!'
.J
B
)
6
9
:1.2
:I.
~;
1.8
11.
2'+
27
1-
'+
7
1,1-
10
:1.3
1'+
:L6
:1.7
19
20
22
23
2~5
26
pB
333
A~3
3pl
0 0 0 2 0 0 0 0
()
A
0
()...----
_____
The shape
as
argument
1
o 2
o 0 0 acted on.
pA
3 3
A<lH:
1:lB
:1.0
4·
"7
19
13
16
1
'1
,.)
..
,
25
If
"7
1
10
:1.3
:1.6
19
")
.:
..
1")1::-
...
23
1:1.
17
20
1'+
21.)
:1.7
1:1.
1'+
20 21
'1
I!.
2:5
....
1
26
2 3
8
c·
...
,
2
I::'
,J
8
'---
6
The first coordinate (planes)
therefore,
9
1,2
15
:1.8
The first
in each plane
rotated
between planes.
2l
2'+
27
A<I>[2JB
3
6
L
9 The second coordinate (rows)
12
:I.
~5
:I.B
2'+
27
therefore,
1
0
0
than
the
rank
of
argument
the
coordinate
of
argument A must be
B less
the
coordinate being
the
rotation
element
is
one
position 0 2
the
rotation
/,------
R
otation
0
0
2 0
0
he first plane t
Rotation between rows
he second plane
t
Rotation
0
he
t
must
B.
The
being
the
is
specified;
is
between planes.
0 0
0
0
is
specified;
is
between
third
the
between rows
between rows
plane
be a scalar
acted
same
rows.
Argument A
or
an array with a
shape
of
argument A
on:
~ArgUment
The middle
element
plane
positions between
planes.
of
of
of
in
is
rotated
must
A
each
two
92
Page 97
(
The
lsi
The ~ symbol
Function: Transpose, Generalized Transpose m
is
formed
by
overstriking the 0 symbol and the \ symbol.
CTI
(
Monadic (One-Argument) Form: Transpose
The
transpose
any expression.
the
function:
function
~'ABCD'
reverses
If
argument B
the coordinates
is
a scalar
ABeD
B~"2
B
2 3
...---------
c:.
,.I
6
~B
4
...
...----------
c:-
~
6
B-t
B
"
.:..
6
10
II
..
2
3
'7
:l
:1.
:L
'.~
1
2
3
~B
of
argument B. Argument B
or
vector, the argument
2-row 3-column matrix.
3-row 2-column matrix.
is
unchanged
can
by
be
("
/
('~'
c
2
6
10
3
7
1t
4-
8
12
1
~:;
jn
"
2:'5
~B
16
20
'1
2ll-
1'4·
1t3
22
1
1
4,
18
22
j
1::-
,
,J
~
:1.9
::.~3
16
20
24·
The coordinates are reversed.
93
Page 98
Dyadic (Two-Argument) Form: Generalized Transpose
A~B
The generalized
specified by argument A. Argument B can be any expression. Argument A must
be a vector or a scalar, and must have an element for each coordinate
also, argument A must contain all
specified. For example,
would be 2 1:
Hf·2
transpose
~3~)
:I.
function interchanges
the
integers between 1 and
to
transpose
the
rows and columns of a matrix, argument A
the
coordinates of argument B
of
the
largest integer
argument
H
:I.
2
:~
I::'
I.~
••
J
6
1"\
.:.:
:I.~B
I.J.
1
11
AM
5
3 6
To
transpose
would be 1 3 2:
1
t::"
\J
9
13
:1.7
21
:I.
2
3
l~
13
:1.4·
15
11.>
B~"2
B
I")
tI..
6
10
1
1
.1.
1B
22
1.
r:
..J
~)
7
B
17
:LB
19
20
the
rows and columns
I.J.
f) \ 2
~5
M1.
..
)
4·
"l
B
:I.
:I.
12
:1.
!7;
:1.1.>
20
19
21.1·
23
3
2~B
9
10
1:1.
12
2:1.
22
23
~~l~
of
a 3-rank (three-coordinate) array, argument A
1
.J.
An array with
The second and third coordinates have been interchanged,
forming an array with
columns.
two
planes, three rows, and four columns.
two
planes, four rows, and
three
as
B;
94
Page 99
The?
Function: Deal
Monadic (One-Argument) Form
the
See
Dyadic (Two-Argument) Form: Deal A?B
The
(depending
arguments must be single positive integers. Argument A must be less than
to
Roll function earlier
deal
function randomly selects numbers from 0 through 8-1
on
the
argument
8;
CD
in
this chapter under
index origin),
argument A determines
without
Primitive
selecting the same number twice.
how
many numbers are selected.
Scalar
Functions.
or
1 through 8
80th
or
equal
I~'
(
..
/
c
95
Page 100
The
.L
Function: Decode
Monadic (One-Argument) Form
There
is
no
monadic
form.
(Base
Value)
CD
Dyadic (Two-Argument) Form: Decode
The
decode
system specified by
decimal
function
number
10
result
is
the
argument
system (base 10):
10
10
A.
1011
1776
The
following illustration shows
Argument A (number
10 10
,L..--+.L...--..Lt-----'--Ten
Argument B
is
7
system) specifies
10
10
equals one unit
to
a vector with these values:
7
6
A.l
value
For
example,
how
it was done:
units
the
B
of
argument
7 7 6
the
in
each
left.
B expressed in
to
convert
following:
of
these positions
of
the
1776
next
the
to
its value
position
number
in
the
The result
x10x10x10
The
arguments
the
other
rank
of
the
is
the
same as doing
x10
x10x10
must
argument
larger
argument
the
following:
:1=
can be a scalar, vector,
6
=
70
=
700
~~The
=
1000
1776
be numeric. If
minus one.
one
The
units position always represents itself.
value
in
the
next
position
by
the
The
value
the
by
and so on.
argument
or
other
rightmost value
in
the
two
rightmost values
is
a scalar or single-element array,
array.
in
next
position
The
result will have
argument A.
in
is
multiplied
is
multiplied
argument A,
the
96
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.