0% found this document useful (0 votes)
107 views

APL360 Users Manual

This publication provides information necessary to use the APL\360 System. It discusses procedures and equipment required for interacting with the system, how to establish connection between terminal and central computer, how to start and end work sessions, and how to apply system control features. Application of the APL language to user problems is thoroughly discussed and appendices give both elementary and advanced examples of actual terminal sessions.

Uploaded by

Molox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

APL360 Users Manual

This publication provides information necessary to use the APL\360 System. It discusses procedures and equipment required for interacting with the system, how to establish connection between terminal and central computer, how to start and end work sessions, and how to apply system control features. Application of the APL language to user problems is thoroughly discussed and appendices give both elementary and advanced examples of actual terminal sessions.

Uploaded by

Molox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 148

APL\360 User's Manual

333330000000000\\\\\LLLLLPPPPP66666\\\\\AAAAAAAAAAAAAAA 66666
333330000000000\\\\\LLLLLPPPPP66666\\\\\AAAAAAAAAAAAAAA 66666
3.333_30.000000000\ \\ \ \LLLLLPPPPP66666\ \ \ \ \AAAAAAAAAAAAAAA 66666
PPPPP AAAAA66666\\\\\66666\\\\\00000 6[)666LLLLL
PPPPP AAAAA66666\\\\\66666\\\\\00000 66666LLLLL
ppppp: AAAAA66666\ \\ \\66'666\\ \\ \00000 66666LLLLL
LLLLL66666 00000 AAAAA\\\\\\\\\\ 00000 \\\\\
LLLLLS6£66 00000 AAAAA\\\\\\\\\\ 00000 \\\\\
LLLLL66666 00000 AAAAA\\\\\\\\\\ 00000 \\\\\
AAAAA0000066666 66666 33333 6666600000 AAAAA
AAAAA0000066666 66666 33333 6666600000 AAAAA
AAAAA0000066666 66666 33333 6666600000 AAAAA
PPPPP66666LLLLLOOOOO\\\\\ PPPPP\\\\\ AAAAAOOOOO
PPPPP66666LLLLLOOOOO\\\\\ PPPPP\\\\\ AAAAAOOOOO
PPPPP66666LLLLLOOOOO\\\\\ PPPPP\\\\\ AAAAAOOOOO
LLLLL33333PPPPPAAAAA\\\\\ PPPPP 6666600000\\\\\
LLLLL33333PPPPPAAAAA\\\\\ PPPPP 6666600000\\\\\
LLLLL33333PPPPPAAAAA\\\\\ PPPPP 6666600000\\\\\
33333 LLLLLLLLLL\\\\\AAAAALLLLL AAAAA\\\\\\\\\\
33333 LLLLLLLLLL\\\\\AAAAALLLLL AAAAA\\\\\\\\\\
33333 LLLLLLLLLL\\\\\AAAAALLLLL AAAAA\\\\\\\\\\
AAAAA\\\\\3333366666AAAAALLLLL33333PPPPP 66666 00000
AAAAA\\\\\3333366666AAAAALLLLL33333PPPPP 66666 00000
AAAAA\\\\\3333366666AAAAALLLLL33333PPPPP 66666 00000
66666\\\\\66666\\\\\\\\\\PPPPPLLLLLPPPPP\\\\\00000 AAAAA
66666\\\\\66666\\\\\\\\\\PPPPPLLLLLPPPPP\\\\\00000 AAAAA
66666\\\\\66666\\\\\\\\\\PPPPPLLLLLPPPPP\\\\\00000 AAAAA
AAAAALLLLLPPPPP33333LLLLL\\\\\66666LLLLLAAAAAPPPPP\\\\\AAAAA
AAAAALLLLLPPPPP33333LLLLL\\\\\66666LLLLLAAAAAPPPPP\\\\\AAAAA
AAAAALLLLLPPPPP33333LLLLL\\\\\66666LLLLLAAAAAPPPPP\\\\\AAAAA
666666.66666666600000333330000033333LLLLL66666\ \ \ \ \PPPPP33333
66666666666666600000333330000033333LLLLL66666\\\\\PPPPP33333
66666666666666600000333330000033333LLLLL66666\\\\\PPPPP33333
\\\\ 33333LLLLLQ00003333300000AAAAA
\\\.\ ":3 ;3·3 3 :3 LL LLL 0 60 0 0 3 3·3 3 3 0 0 0 a 0 AA AAA
a 00\\\\\ 33333LL~LL000003333300000AAAAA
AAAAAAAAAAOOOOOLLLLL \\\\\LLLLL PPPPP66666
AAAAAAAAAAOOOOOLLLLL \\\\\tLLLL PPPPP66666
AAAAAAAAAAOOOOOLLLLL \\\\\LLLLL PPPPP66666

IBM Thomas J. Watson Research Center


The cover design uses a random pattern generated by the
following APL function:
V Z+M G C
[lJ Z+((2fM)x2+M)p 2 4 1 3 ~((M[3 4J,pC)pC)[;;?M[1 2JppCJ
V

This function was suggested by an algorithm due to Roger


Frey (IBM Research and Yale University). The particular
usage was: 13 13 3 5 G ' APL\360 '
The body of the manual was edited and composed on APL\360
using variations of a text-processing package designed and
implemented by M. M. Zryl (IBM Research), and patterned
after a Fortran system due to A. P. Mullery (IBM Research).

AUGUST 1968 PRINTED IN THE u. S.A.


APL\360: User's Manual

A. D. Falkoff

K. E. Iverson

~ International Business Machines Corporation, 1968


ACKNOWLEDGEMENTS

The APL language was first defined by


K. E. Iverson in A Programming LaD~uage
(Wiley,l962) and has since been developed in
collaboration with A. D. Falkoff. The APL\360
Terminal System was designed with the
additional collaboration of L. M. Breed, who,
with R. D. Moore*, also designed the S/360
implementation. The system was programmed for
S/360 by Breed, Moore, and R. H. Lathwell,
with continuing assistance from L. J.
Woodrum t , and contributions by C. H. Brenner,
H. A. Driscoll±, and S. E. Krueger±. The
present implementation also benefitted from
experience with an earlier version, designed
and pr:ogrammed for the IBM 7090 by Breed and
P. S. Abrams**.
The development of the system has also
profited from ideas contributed by many other
users and colleagues, notably E. E. McDonnell,
who suggested the notation for the signum and
the circular functions.
In the preparation of the present manual,
the authors are indebted to L. M. Breed for
many discussions and suggestions; to R. H.
La thwell, E. E. McDonnell, and J. G. Arnold tt
for critical reading of successive drafts; and
to Mrs. G. K. Sedlmayer and Miss Valerie
Gilbert for superior clerical assistance.
A special acknowledgement is due to John
L. Lawrence, who provided important support
and encouragement during the early development
of APL implementation, and who pioneered the
application of APL in computer-related
instruction.
* I. P. Sharp Associates, Toronto, Canada.
t General Systems Architecture, IBM
Corporation, Poughkeepsie, N.Y.
± Science Research Associates, Chicago,
Illinois.
** Computer Science Department, Stanford
University, Stanford, California.
n Industry Development, IBM Corporation,
White Plains, N.Y.
TABLE OF CONTENTS

PART 1: GAINING ACCESS

PHYSICAL EQUIPMENT 1.1


Preferred features
THE )\PL CHARACTER SET 1.3
Use of other character sets
THE RECORDING TERMINAL 1.4
ESTABLISHING A CONNECTION 1.4
S~t up terminal, Dial computer
ENTRIES FROM THE KEYBOARD 1.6
~~ransmission signals, Mistakes, Transmission
e r ro ra , Special features of IBM 1050 terminals
STAR,]~ING AND ENDING A WORK SESSION 1.8
Sign-on, Limited use of the system, Disconnect
dial-up connection, Break any connection

PART 2: SYSTEM COMMANDS

WORKSPACES AND LIBRARIES 2.1


Workspaces, Libraries
NAMES 2.2
Local and global significance
LOCKS AND KEYS 2.3
ATTENTION 2.4
USE OF SYS~rEM COMMANDS 2.5
Classification of commands, Normal response and
i:rouble reports, Clear workspace, Summary
TERMINAL CONTROL COMMANDS 2.8
Forced endings, The CONTINUE workspace,
Interrupted activities, Detailed description
WORKSPACE CONTROL COMMANDS 2.13
App Li.cet.Lon Packages, Groups, Detailed
description
LIBRJ~RY CONTROL COMMANDS 2.22
Continuity of work, Workspace identification,
IJibrary and account numbers, Storage allotment,
Use of the CONTINUE workspace, Purging a
workspace, Detailed description
INQUIRY COMMANDS 2.28
User codes, Detailed description
COMMtmICATION COMMANDS 2.32
Detailed description
PART 3: THE LANGUAGE

FUNDAMENTALS 3.1
Statements, Scalar and vector constants, Names
and spaces, Overstriking and erasure, End of
statement, Order of execution, Error reports,
Names of primitive functions
SCALAR FUNCTIONS 3.5
Monadic and dyadic functions, vectors, Index
generator
DEFINED FUNCTIONS 3.10
Introduction, Branching, Local and global
variables, Explicit argument, Explicit result,
The forms of defined functions, Use of defined
functions, Recursive function definition, Trace
control
MECHANICS OF FUNCTION DEFINITION 3.17
Labels, Revision, Display, Line editing,
Reopening function definition, Locked functions,
Deletion of functions and variables, System
command entered during function definition
SUSPENDED FUNCTION EXECUTION 3.20
Suspension, State indicator, stop control
HOMONYMS 3.22
Variable names, Function names
INPUT AND OUTPUT 3.23
Evaluated input, Character input, Escape from
input loop, Normal output, Heterogeneous output
RECTANGULAR ARRAYS 3.26
Introduction, Vectors dimension catenation,
Matrices dimension ravel, Reshape, Uses of empty
arrays, Indexing, Indexing on the left, Index
origin, Array output
FUNCTIONS ON ARRAYS 3.33
Scalar functions, Reduction, Inner product,
Outer product
MIXED FUNCTIONS 3.37
Introduction, Transpose, Monadic transpose,
Rotate, Reverse, Compress, Expand, Decode,
Encode, Index of, Membership, Take and drop,
Grade up and down, Deal, Comments
MULTIPLE SPECIFICATION 3.45
SYSTEM DEPENDENT FUNCTIONS 3.46

PART 4: LIBRARY FUNCTIONS

APPENDIX A
SAMPLE TERMINAL SESSION
APPENDIX B
ADVANCED EXAMPLES
BIBLIOGRAPHY
LIST OF ILLUSTRATIONS

']~able 1.1 RECOMMENDED FEATURES AND 1.2


OPTIONS FOR TERMINALS

E'igure 1.2 APL\360 KEYBOARD 1.3

']~ab Le 1. 3 TELEPHONE NUMBERS 1.5

'I'ab1e 2.1 SYSTEM COMMANDS 2.7

'I'ab1e :3. 1 ER.ROR REPORTS 3.4

'I'ab1e 3.2 PRIMITIVE SCALAR FUNCTIONS 3.6-7

'I'ab1e 3. 3 FORMS OF DEFINED FUNCTIONS 3.15

'I'ab1e 3.4 DIMENSION AND RANK VECTORS 3.27

'I'ab1e 3. 5 IDENTITY ELEMENTS OF PRIMITIVE 3.34


SCALAR DYADIC FUNCTIONS

'I'ab1e 3. 6 INNER PRODUCTS FOR PRIMITIVE 3.36


SCALAR DYADIC FUNCTIONS f AND g

'lIable 3. 7 OUTER PRODUCTS FOR PRIMITIVE 3.36


SCALAR DYADIC FUNCTION g

'lIable 3. 8 PRIMITIVE MIXED FUNCTIONS 3.38

T'a b 1 e 3. 9 TRANSPOS ITION 3.40

T'a b 1 e 3.10 SYSTEM DEPENDENT FUNCTIONS 3.47


PART 1
GAINING ACCESS

An APL\360 System comprises a £gnt~.91 £QID2ytg±: and an


indefinite number of typewriter-like t§±:ID!n~1§. A certain
number of these terminals may be simultaneously linked to
the computer, according to t.he number and type of access
2Q~~§ on the computer.

This part of the manual describes the terminal


equipment required for interacting with the system, tells
how to establish a connection between a terminal and the
central computer, and gives, in simplest form, the
procedu.res for starting and ending a work session.
PHYSICAL EQUIPMENT
A remote terminal for use with the system must be
either an IBM 2741 Communications Terminal, an IBM 2740-1
Communications Terminal equipped with the Transmit Control
feature, or an IBM 1050 Teleprocessing Terminal. It may
connect to the central computer through the dial-up
telephone network, by a leased telephone line, or by private
wire.
Dial-up connections are effected by means of a Western
Electric Dataset #103A-2 or the equivalent, or a compatible
acoustic coupler. A leased telephone line connection
requires the use of a Western Electric Dataset #103F-2 or
the equivalen1:. A direct-wired connection is effected by
means of an appropriate IBM line adapter (modem). In the
last case, "two-wire connections should be avoided, if
possible, since their use rules out an interrupt facility.
~~§f§~~§g f§~tY~§§. The APL\360 system will work with many
variations of the terminal types given above, but certain
features and options are desirable. Dial-up connections
provide the greatest flexibility, both in overall system
configuration, and in certain details of operation.
Similarly, although the APL printing element is based on a
12-pitch font, and is available in both Selectrice and
p~rTC/BCD keyboard encoding (i. e., the correspondence between

1.1
FEATURE OR OPTION 1050 2740-1 2741

Control Unit 1051-2


Voltage (115 AC), Non-lock plug 9881 9881 9881
Dataset Attachment 9114 9114 9114
Dial Up NR 3255 3255
Transmit Control NR 8028 NR
Automatic EOB RPQ E27283 Do not use NR
Typamatic Keys NA NA 8341
Interrupt RPQ E27428 RPQ F17913 4708
Text Time-out Suppression 9698 NR NR
First Printer Attachment 4408 NR NR
Automatic Ribbon Shift Select 1295 NA NA
Typing Table 9705 NR NR
Printer-Keyboard 1052-2
APL Printing Element, PTTC/BCD 1167988 1167988 1167988
or Standard Se1ectric~ NA 1167987 1167987
Keys, APL Keyboard RPQ M40174 RPQ M40174 RPQ M40174
Character Spacing, 10 per inch 9104 9104 9104
Line Feeding, 6 per inch 9435 9435 9435
Accelerated Carrier Return 1006 NA NA
Notes. NR: feature is standard equipment, or is not required.
NA: not available (July 1968).
The numbers are IBM-domestic identifications.

Table 1.1: RECOMMENDED FEATURES AND OPTIONS FOR TERMINALS

keyboard layout and character positions on the printing


element), specification of 10-pitch character spacing and
Se1ectric~ encoding will allow a greater variety of printing
elements to be used with the terminal. While it is not
essential, the convenience of having the interrupt feature
cannot be overestimated.

Paper tape equipment (1054-1 Reader and 1055-1 Punch)


and punched-card equipment (1056-1 Reader and 1057-1 Punch)
can be used with IBM 1050 terminals. The punched-card
facilities should have Extended Character features 3861 and
3860, for reader and punch, respectively.

IBM identifications for recommended terminal features


and options are given in Table 1.1. Complete specifications
for terminals, and information on other options, should be
obtained from local IBM representatives.

1.2
[iliD;....-""-~~~---"';;' ~--"-~-"--~I\..,-~~ ~
? w
Q W

[~ J_~~~ __~_~_~_~_~_~_~_~~~~~
F J K

[SHIFT~ B
Figure 1.2: APL\360 KEYBOARD

THE APL CHARACTER SET

The APL\360 keyboard is shown in Figure 1.2. The


numerals, alphabetic characters, and punctuation marks
appear in their usual places, although the alphabet is used
in only a single case: letters print as upper-case italics,
but are produced only when the keyboard is in lower-case
position (i.e~, not shifted).

The special characters, most of which are produced with


the keyboard shifted, generally have some mnemonic
connection wi 1:h their alphabetic or numeric correspondents.
This may be appearance (w over W), Greek-Roman equivalence
(p over R), sequence « $ = ;::: > ;t over 3 4 5 6 7 8), or some
possibly far fetched -- relationship between the APL
function represented by the symbol and the letter (* over P
f oz' 12ower, ' over K for "kwote ", and rover S for Qeiling).

JJ':2.e Qf Qth.ex-
.cbg..ra.Qte.r §ets. The part numbers of APL
printing elements are given in Table 1.1. However, any
pz'Lrrt.Lnq element may be used wi th the APL system, since the
encoded characters generated by the keyboard and transmitted
to the comput.er are independent of the particular element
mounted on the ,terminal. Subject to programmed
intervention, the transmitted information will always be
interpreted according to the APL keyboard characters.

Non-APL printing elements are frequently useful in


oon [unct.Lon with special-purpose APL programs designed to
exploit their character sets. Also, any element that
matches the keyboard encoding (Selectric e or PTTC/BCD) of
the terminal can be used for straightforward numerical work,
since Le t t.e ra and digi ts print properly with such elements.
The visual int:erpretation of complex APL expressions is, of
course, awkward with any but an APL printing element.

1.3
THE RECORDING TERMINAL
As connections with remote terminals are established
and broken, and users start and end work sessions, a printed
record of this traffic is generated at the system's
~§gQ~g~ng t§~IDingl. This terminal, which is usually, but
not necessarily, located at the central computer site, is
ordinarily attended by an AEL Q~eratQr who monitors the
operation of the system, and provides a common point of
contact for users.
There are certain supervisory functions, essential to
the operation of APL\360, which can be effected only from
the recording terminal. Thus, this terminal holds a
privileged position relative to others. The enrollment of
new users, and the allocation of library space, are examples
of this kind of function.

ESTABLISHING A CONNECTION
The directions that follow assume the use of a dial-up
connection with a dataset. Instructions for the use of
acoustic couplers should be obtained from their suppliers.
Where terminals are connected to the computer by leased
lines or private wires, instructions on dialing procedure
(EC2) are irrelevant, but local sources of information
should be consulted for equivalent procedures.

~~1~ ~~!:yp .!:g~1!lj.D.§.1:


Insert paper, mount an APL
printing element, connect
terminal to power source,
and set switches as follows:
IBM 2741 or 2740 Terminal
LCL/COM COM The power switch is at the
Power ON right of the keyboard. On
2741's, the LCL/COM switch
is on the left side of the
terminal stand, toward the
rear; on 2740's, it is to
the right of the power
switch.

1.4
IBM 1050 Terminal
ATTEND/UNATTEND A'rTEND Not all 1050's have all
Keyboard SEND switches; those present must
Printer SEND-RECEIVE be set as indicated. The
Reader 1 OFF states of switches not
Punch 1 OFF listed here are immaterial.
EOB MANUAL
Line .test OFF If it is known that RPQ
Single step OFF E27283 (see Table 1.1) is
Line control ON installed, set the EOB
Power ON switch to AUTO.
The line control switch is
inside the rear door of the
1051 Control Unit. The
power switch is on the left
side of the control unit,
toward the front.

On 2741 and 2740 terminals, If the keyboard does not


best to see if the keyboard lock after a carrier return,
is locked by trying the check the switches and try
shift key. If the key is once more. If the switches
operable, press the carrier are set properly and the
return and test again. keyboard remains unlocked,
the terminal is faulty.

~~~2.£ ~!E:l .9QIDI?Y~§1;": Telephone numbers are given


Sf=t the telephone pushbutton in Table 1.3. If the line
sw i, tch to TALK and follow is busy, try a different
ordinary dialing procedure. number or call the APL
After two rings, at most, Operator to inquire about an
the telephone will respond open line.
with a steady, high-pitched
tone.
123 456-7890 123 456-7890
Insert a table of access
telephone numbers here.
An assistance number
should be included.

APL Operator: 123 456-7890

Table 1.3: TELEPHONE NUMBERS

1.5
Promptly set the pushbutton The DAT~ button should
switch to DATA by holding light, and will remain· lit
the DATA button down firmly as long as the terminal is
for a moment and then connected to the computer.
releasing. If it does not light, check
the power connection to the
Cradle the handset. dataset. If it lights, but
quickly goes out, check the
power connection to the
terminal, the cable
connection to the dataset,
and the switch settings on
the terminal. Then retry
from Eel.

B§§2Qn§~: The keyboard will


unlock, indicating that the
computer is ready to accept
an entry from the terminal.
The connection established by the foregoing procedure
is only tentative, and will be broken by the central
computer if further communication does not take place within
60 seconds. Therefore, the next step the sign-on
procedure (EC3) given below -- should be executed promptly.

ENTRIES FROM THE KEYBOARD


After a connection is established, normal communication
between a tie rmi ne L and the central computer is carried on by
means of entries from the typewriter keyboard, which
alternately locks and unlocks as each entry is made and the
computer completes its work. The general procedure is to
type an instruction or command, strike the ggIIi~I I~tYID to
indicate the end of the message, and follow this by a
transmission signal.

1~~~§IDi§§iQ~ §ig~§l§. The transmission signal is generated


differently, according to the terminal type and its
equipment:
2741. A transmission signal is automatically generated in
the proper sequence (L, e. , after tr..e carrier return
signal) when the RETURN key is struck.
~l~Q. The transmission signal is produced by striking the
EOT key after the RETURN key. (Do not use the the EOB
key, or the automatic EOB feature available on these
terminals. )

1.6
10.5.0 I. On terminals equipped wi th an automatic EOB RPQ
(see Table 1.1), the transmission signal is produced
automatically when t.he RETURN key is struck. Otherwise,
an EOB must be produced manually, by striking the
nume r a.l-eS key, while the key marked ALTN CODING is
belg dQ~D. (Note that the automatic EOB feaxuIe available
for 1050 terminals cannot be used with APL\360.)
A, transmission signal does not cause a character to be
printed, and its omission will therefore be evidenced only
by the state of the terminal: the keyboard will remain
unlocked, and no response will be forthcoming from the
system.
In the remainder of this manual the need for carrier
return and 'transmission signal will not be explici tly
mention.ed, since they are required for .eY.er~ entry.
Mis.takfH3.. Before the carrier return (and transmission
signal) that completes an entry, errors in typing can be
co r.re c te d as follows: backspace to the point of error and
then depress the linefeed button (marked ATTN on 2741
terminals). ~rhis will have the effect of eras ing everything
to the right of, and including, the position of the carrier.
The corrected text can be continued from that point, on the
new line.
This procedure can be used at any time once the sign-on
(EC3) has been accomplished. In case of error in the
sign-on itself, the entry should be made as is. The system
will provide an appropriate .t~Quble repQrt, following which,
a correct entry may be made.

X;r;:a.o.smisaiQn
.errQrs. There are occasional transient
failures in the communication between a terminal and the
cerrt r a L computer. If the failure occu.rs during the
transmission from the terminal, the system will respond with
a I'§§§;n.g signal: on 1050 terminals, the RESEND warning
light will go on, and on other terminals the message RES END
will be print:ed. In any case, the last entry from the
keyboard must be repeated. The warning light on the 1050
should first be extinguished by pressing the adjacent
button.
Failures in the other direction are usually evidenced
by the appearance of a spurious character, whose presence in
the printed output is obvious in most contexts. However,
there is no absolutely certain way of detecting such a
failure.

1.7
S~ecigl features 01 IEM lQ5D terminals. The keyboard of a
terminal equipped with a REQUBST button will not unlock,
when it otherwise should, until the button is depressed. On
terminals equipped with a timer, the keyboard will lock
before an entry is completed if approximately 18 seconds
have elapsed since the last keyboard action. Locking can be
forestalled by occasionally striking the shift key, but if
it does happen, the keyboard can be forced to unlock by
flipping the line-control switch inside the 1051 Control
Unit to OFF, and back to ON.
If a terminal is to be used exclusively with APL\360,
the Keyboard Request feature should be removed, and the Text
Time-out Suppression feature should be added.

STARTING AND ENDING A WORK SESSION


Each user of the system is assigned an ~..9.J.ulj:. ...ru:Lmp_e_r.
This number is used to effect the sign-on tr..at initiates a
work s es s Lon j serves to partially identify any work that the
user may store in the system between sessions; and is used
for accounting or billing purposes.
If the account number is not known, or if one of the
trouble reports given below is encountered and not
understood, a message of inquiry can be sent to the APL
Operator. This is accomplished by entering) OPR followed by
a space and one line (not exceeding 120 characters) of an
appropriate text.
Such a message can be sent at any time after a
connection has been established. It causes the keyboard to
lock, awaiting a reply. If no reply is forthcoming, (and
the sign-en has not been completed), the connection will
have to be broken and re-established before further
communication with the system is possible. (After the
sign-on, the keyboard may be unlocked by an ~~~~~
EiE~E~' descyibed in Part 2.)

~~)-! 9j...9~ .9Il: The use of passwords as


Enter ) locks and keys is described
followed by an account in Part 2. A new user will
number, with a key (i.e., a have been advised if a key
colon and password), if is required for his first
required. sign-on.

1.8
1~.t.f§.9~ :
1. A workspace will be A workspace can be thought
activated for the terminal. of as both a notebook and a
scratch pad. The details
2. Accumulation of time are explained in Part 2.
charges will begin.

l~'§.P..9.!tf?~: j:'..r..9~b..le ..r.e-p.o..rJ:...s:


1. A broadcast message from NUMBER NOT IN SYSTEM
t:he APL Operator may be means either exactly what it
printed. says, or that the number has
a lock associated with it
2:. The port number, time of and the wrong key was used.
day, date, and user name The APL Operator should be
associated with the account consulted if help is
number will be printed on required.
one line. The system
identification will be INCORRECT SIGN-ON
printed on another line. means the form of the
transmitted command was
faulty. Retry with a
properly formulated sign-on.
ALREADY SIGNED ON
means that a work session is
already in progress at the
terminal. To start a
session with a different
account number, use command
TC5 (see Part 2), which ends
the current session but
holds the connection, and
retry from the beginning of
EC3.
NUMBER IN USE
means just that, or a
temporary condition due to
delays in the central
computer. Retry from EC2
after two minutes. If the
condition persists, notify
the APL Operator.
NUMBER LOCKED OU'1.'
means that authori.zation for
use of that number has been
withdrawn.

1.9
3. SAVED, follow\~d by the This response will be
time of day and date that omitted if the activated
the activated workspace was workspace is ~1~9L (i.e.,
last stored. not holding information).
If the respc:nse is given,
the workspace is named
CONTINUE. The use of
workspace names is explained
in Part 2.
4. The keyboard will be If this is the only reponse,
unlocked. a transmission error has
occurred, or the entry did
not start with an APL right
parenthesis. In either
case, the ent.ry should be
repeated in correct form.
If the condition persists,
retry from EC2, possibly
dialing a different number.

A work session is started, and the full APL system


becomes available, once the sign-on is accomplished. Any
system command of Part 2 or APL operation of Part 3 may now
be entered for execution.

Liroit~g Q.s~Q-f .tb.e .s~.s.t.eID. No system command other than the


sign-on given here is required in order to make use of Part
3, and the reading of Part 2 may therefore be deferred if
only casual or restricted use is to be made of the system.
For the purposes of such use, a work session may
conveniently be terminated by one of the following
procedures:
AC!IQN NQ~ES

EC~~ QiS~QnD~~t gial=Y~ Use this procedure for


.QQDD§.QtiQD: dial-up connections QD1~ .
Set the power switch to OFF.
Effec·t :'
l~-The active workspace will If the workspace is clear,
be stored wlder the name it will not be stored at
CONTINUE. this time. If it is stored,
it will be automatically
re-activated when the same
account number is next used
to sign on. See note for
EC3, Response 3.

1.10
:2. The duration of the work
ae aai.on and the amount of
compucez time used wil'l. be
noted internally for later
accounting.

3. The connection to the


cerrt.rel, computer will be
broken.

The DATA light will go out.

I~Q.2£ ;§~§gk ~nlY QQnn§gti:Qn: This is command TC4,


Enter ) CONTINUE detailed in Part 2.

!~ff§gt:
JL. 2. arid 3. The same as for
EC4.

!~§§'I2QDJ~§: ~;r;;:QYQle J;;:§!2.QJ;;::ts.:


1. Time of day and date, NOT WITH OPEN DEFINITION
followed by CONTINUE INCORRECT COMMAND
The meanings of these
reports, and corrective
actions for them, are given
in Part 2.

2. The port number, time of User codes comprise three


day, date, and user code characters which partially
\firill be printed. identify users. Their use
is explained in Part 2.
~~. AcoourrtLnq information
\firill be printed. If a dial-up connection is
being used, the DATA light
will go out.

1.11
PART 2
SYSTEM, COMMANDS

APL operations deal with transformations of abstract


objects, such as numbers and symbols, whose practical
significance, as is usual in mathematics, depends upon the
(arbitrary) interpretation placed upon them. Sy:.§,tgm
gQIDIDgn9§ in the APL\360 System, on the other hand, have as
their subject the structures whi.ch comprise the system, and
control functions and information relating to the state of
the system, and therefore have an immediate practical
significance independent of any interpretation by the user.
In this Part the structure of the APL\360 system is
described, and various notions essential to the
underst.a.nding of system commands are introduced. Finally,
the complete set of system commands is described in detail.

WORKSP~.CES AND LIBRARIES


NS~.f~'§2§:2~'§. The common organizational unit in the APL\360
system is the ~Q!'~'§12,9.g§. When in use, a workspace is said
to be .§,9!;;1yg, and it occupies a block of working storage in
the central computer. The size of the block, which is
preset at a fixed value for a given system, determines the
combined working and storage capaci ty of each 'workspace in
that system. Part of each workspace is set aside to serve
the internal workings of the system, and the remainder is
used, as required, for storing items of information and for
containing transient information generated in the course of
a computation ..
An active workspace is always associated with a
terminal during a work session, a:ld all transactions with
the system are mediated by it. In particular, the names of
Y~~!'1gQ!§'§ (da1:a items) and g§fi!!gg fy!!g!;iQ!!.§ (programs) used
in calculations always refer to objects known by those names
in the active workspace; information on the progress of
program execution is maintained in the .§!;g!;§ in~1£g!;Q~ of
the active workspace; and control information affecting the
form of outpu1: is held within the active workspace.

2.1
~1Q~g~!g§. Inactive workspaces are stored in lig~g~i~§,
where they are identified by arbitrary names. They occupy
space in secondary storage facilities of the central
computer and cannot be worked with directly. When required,
copies of stored workspaces can be made active, or selected
information may be copied from them into an active
workspace.

Libraries in APL\360 are either Q~iy~t§ or 2g~lig.


Private libraries are associated with individual users of
the system, and are identified by the user's account number.
Access to them by other users is restricted in that one user
may not store workspaces in another person's library, nor
can he obtain a listing of the workspaces already stored
there. However, one user may activate a copy of another
user's (unlocked) workspace if he knows the library number
and workspace name.

Public libraries are identified by numbers below 1000.


They are not associated with individual users, although
certain ones may be reserved by general agreement for groups
of people working cooperatively. Anyone may store
workspaces in a public library, and a listing of workspace
names is available upon request if the library number is
known. However, a workspace stored in a public library
remains under the control of the user who put it there, and
cannot be altered by others.

NAMES

Names of workspaces, functions, variables, and groups


(see workspace control commands) may be formed of any
sequence of alphabetic (A to Z, and d to ~) and numeric (0
to 9) characters that starts with an alphabetic and contains
no blank. Only the first 11 characters of workspace names,
and the first 77 characters of other names are significant.
Longer names may be used, but additional characters beyond
these limits are ignored.

The environment in which APL operations take place is


bounded by the active workspace. Hence, the same name may
be used to designate different objects (i.e., groups,
functions, or variables) in different workspaces, without
interference. Also, since workspaces themselves are never
the subject of APL operations, but only of system commands,
it is possible for a workspace to have the same name as an
object it holds. However, the objects within a workspace
must have distinct names, except as explained below.

2.2
~Qg~l ~n~ glQb~l ~ignifig~ng§. In the execution of defined
functions it is often necessary to work with intermediate
results which have no significance either before or after
t:he function is used. To avoid cluttering the workspace
with a multitude of variables introduced for such transient
purposes, and to allow greater freedom in the choice of
names, the function definition process (see Part 3) provides
a facility for designating certain variables as lQg~l to the
function being defined. Variables not so designated, and
all functions and groups, are said to be glQf?§:l.
A local variable may have the same name as a global
object" and any number of variables local t.o different
f unc t Lon s may have the same name.

During the execution of a defined function, a local


variable will supersede a function or global variable of the
same name, temporarily excluding it from use. If the
execution of a function is interrupted (leaving it either
§Y§~§n~§~, or 2§n~§n~, see Part 3), the local variables
retain their dominant position, during the execution of
subsequent APL operations, until such time as the h9:ltsH~
function is completed. System commands, however, continue
t:o reference the global homonyms of local variables under
t:hese circumstances ..

I~OCKS ~zrnD KEYS


Stored workspaces and the information they hold can be
protected against unauthorized use by associating a 1Q9~,
Gomprising a colon and a 29:§§~Q!,g of the user's choice, with
t:he name of the workspace, when the workspace is stored. In
order to acti.vate a locked workspace or copy any information
i.t contains, a colon and the password must again be used, as
a ~§y, in conjunction with the workspace name. Listings of
workspace names, including those in public libraries, never
give the keys, and do not overtly indicate the existence of
a Lo ck ,

Account numbers can be similarly protected by locks and


keys, thus maintaining the security of a user's private
library and avoiding unauthorized charges against his
account.
Passwords for locks and keys may be formed of any
sequence of alphabetic and numeric characters up to eight
characters long, without blanks. Characters beyond the
eighth are ignored. In use as either a lock or key, a
password follows the number or name it is protecting, from
which it is set off by a colon.

2.3
ATTENTION
Printed output at a terminal can be cut off, or the
execution of an APL operation can be interrupted, and
control returned to the user, by means of an gtt~DtiQD
~ign~b. Since the keyboard 1S locked during printing or
computing, the signal must be generated by means other than
one of the standard keys.
On terminals equipped with an interrupt feature, the
attention signal is generated by depressing the appropriate
key once, firmly. On IBM 2741 terminals this key is usually
of a distinctive color, and is marked ATTN. (The same key
is used for linefeed when the keyboard is not locked.)
For terminals not so equipped, the attention signal is
generated by momentarily interrupting the connection to the
central computer. The method depends upon the type of
connection:
with dial-up telephones, uncradle the handset, set
the pushbutton switch to TALK for two to three
seconds, and then reset it to DATA;
with leased telephone lines, set the terminal power
switch to OFF and then back to ON, with deliberate
speed.
If the connection is broken, in either case, for more than
five seconds, the central computer will interpret this as a
signal to end the work session and will execute action EC4
of Part 1.
Following an attention signal the keyboard will unlock,
and the type carrier will return to the normal position for
input (six spaces from the left margin). If the carrier
does not do this, enter blank lines repeatedly until it
does. In some cases a line will be printed before the
keyboard unlocks, telling where a function in progress was
interrupted.
Except for communication commands (and then only if the
delivery of a message is delayed), the execution of system
commands, once entered, cannot be interrupted. However, the
printed responses or trouble reports following a system
command can be suppressed by a properly timed attention
signal.

2.4
USE OF SYSTEM COMMANDS
System
commands and APL operations are distinguished
;~.YD.9.ti-,QDg.1J:..Y
by the fact that system commands can be called
for only by individual entries from the keyboard, and cannot
be executed dynamically as part of a defined function. They
are distinguished in iQ~ by the requirement that system
commands be prefixed by a right parenthesis, which is a
syntactically invalid construction in APL.
There is some system control which it may be desirable
to exert dynamically, and there are some items of system
information which can be profitably used during the
execution of a program. For these purposes APL\360 provides
appropriate .§.Y.§.tgID=.9g12~DggD.t .fYDgtiQD~ and .1ibX.9J:Y
JYD.9.tigD.§, wh i ch can be used like other APL operations.
These functions are described in Part 3 and Part 4,
z'e s peot.LveLy , Where a system command duplicates the action
of one of them, this fact will be noted in the description
of the system command in this Part.
All syst:em commands can be executed when the terminal
i.s in the g~§.9Y.t1QD IDQ.9§, in which APL operations are
exe cut.e d forthwith upon entry. However, in .9g.fiIli.t.iQD IDQ.9g,
in which sequences of operations are being composed into
functions for later execution, commands which call for
storin9 a copy of the workspace, or which might otherwise
interfere with the definition process itself, are forbidden.
(The t\Y'O terminal modes are treated more fully in Part 3.)

~lg'§'§.!~~.!.9.9.t.!QD
Q.t .9QIDIDBD9'§ • Sy stem commands are
conveniently grouped into five classes with regard to their
effect upon the state of the system:
1 .. ~g~ID.!n.9.! .9Qn.t~Q.! commands affect the relation of a
t.e rmi na L to the system.

2 .. NQ1;~'§12'§'Qg gQn.t~Q.! commands affect the state of the


active workspace.
3.. ~.!.t>~.9~y QQn.t!'Ql commands affect the state of the
libraries.
4.. Ingy.!!'y commands provide information without
affecting the state of the system.
5., 'cQmIDyn.!gg..t.!Qn commands effect the transmission of
me s saqe s among terminals.

2.5
The text that follows is based upon this
classification, although it will be seen that certain of the
terminal control commands also affect the libraries, and one
of the library control commands may sometimes affect the
state of the active workspace.

NQ~mgl ~§§QQn§§§ gng t~QYbl§ ~§QQ~t§. Any entry starting


with a right parenthesis will be interpreted by the system
as an attempt to execute a system command. When the command
is successfully executed, the nQ.mg1 ~§§QQn§§, if any, will
be printed. This response is given in the description of
the action for each command.
If, for any reason, a command cannot be executed, an
appropriate .t~QYQ1§ ~§QQ~:t will be printed. The most corrnnon
report is INCORRECT COMMAND. This means that the command
was incomplete, mis-spelled, used a wrong modifier, or was
otherwise malformed. The corrective action in every case is
to enter a properly composed command. The meanings and
corrective actions for other trouble reports are given in
the notes accompanying the description of each command.

Clgg~ ~Q~~§~9g§~ There are certain transient failures of


the system which cause the active workspace to be destroyed.
If this should occur, the message CLEAR WS will be printed,
indicating that the active workspace has been replaced by a
gl§g~ workspace. (The attributes of a clear workspace are
given in the section on workspace control commands, see
WeI.) This situation rarely arises, but the probability of
its occurrence is slightly higher during the execution of
system commands.

QYmIDg~~. The purposes, forms, responses, and trouble


reports for all system commands are summarized in Table 2.1.
Where the first word of a command form is more than four
characters long, only the first four are significant. The
others are included only for mnemonic reasons, and may be
dropped or replaced, as desired. For example, )CLEAR,
)CLEA, )CLEAVER, etc., are all equivalent.
In general, the elements of a command form must be
separated by one (or more) spaces. Spaces are not required
immediately following the right parenthesis, or on either
side of the colon used with passwords, but can be used
without harm.

2.6
Reference and Purpose
COMMAND FORM 1,2,3 NORMAL RESPONSE TROUBLE REPORTS"
1-----------------------------------------.-------------------4
TCl Sign on designated user and start a work session.
)NUMBER [KEY] [TEXT]; PORT, TIME,.DATE,USER; SYSTEM; [SAVED ,TIME,DATE] 1 2 3 4 5
TC2 End work session.
)OFF [LOCK] PORT,TIME,DATE, USER CODE; TIME USED 16
TC3 End work session and hold dial-up connection.
)OFF HOLD (IJOCK] PORT,TIME,DATE,USER CODE; TIME USED 16
TC4 End work session and store active workspace.
)CONTINUE [LOCK] [TIME,DATE,CONTINUE]; PORT,TIME,DATE, USER CODE; TIME USED 6 16
TC5 End work session, store active workspace, and hold dial-up connection.
)CONTINUE HOLD [LOCK] [TIME,DATE,CONTINUE]; PORT, TIME, DATE,USER CODE; TIME USED 6 16
WC1 Activate a clear workspace.
) CLEAR CLEAR WS 16
WC2 Activate a copy of a stored workspace.
)LOAD WSID [KEY] SAVED,TIME,DATE 7 8 16
WC3 Copy a global object from a stored workspace.
) COPY WSID [KEY] NAME SAVED, TIME, DATE 6 7 8 9 10 16
WC3a Copy all global objects from a stored workspace.
) COPY WSID [KEY] SA VED , TIME, DATE 6 7 8 10 16
WC4 Copy a global object from a stored workspace, protecting active workspace.
)PCOPY WSID [KEY] NAME SAVED,TIME,DATE; [NOT COPIED: ,LIST OF OBJECTS] 6 7 8 9 10 16
WC4a Copy all global objects from a stored workspace, protecting acti.ve workspace.
)PCOPY WSID [KEY] SAVED,TIME,DATE; [NOT COPIED: ,LIST OF OBJECTS] 6 7 8 10 16
WC5 Gather objects into a group.
)GROUP NAME[S] NONE 11 16
WC6 Erase global objects.
)ERASE NAME[S] [NOT ERASED: ,LIST OF OBJECTS] 16
WC7 Set index origin :Eor array operations.
)ORIGIN INTE:GER,O-l WAS ,FORMER ORIGIN 16
WCO Set maximum for significant digits in output.
)DIGITS INTEGER,1-16 WAS ,.FORMER MAXIMUM __ 16
WC9 Set maximum width for an output line. TROUBLE REPORT FORMS
)WIDTH INTEGER, 30-130 WAS ,FORMER WIDTH 1 NUMBER NOT IN SYSTEM 16
WClO Change workspace identification. 2 INCORRECT SIGN-ON
) WSID WSID WAS, FORMER WSID 3 ALREADY SIGNED ON 16
LC1 Re-store a copy o:E the active workspace. 4 NUMBER IN USE
)SAVE TIME,DATE,WSID 5 NUMBER LOCKED OUT 6 12 13 14 16
LC1a Store a copy of the active workspace. 6 NOT WITH OPEN DEFINITION
)SAVE WSID [LOCK] TIME, DATE 7 WS NOT FOUND 6 12 13 14 16
LC2 Erase a stored workspace. 8 WS LOCKED
)DROP WSID TIME, DATE 9 OBJECT NOT FOUND 7 14 16
101 List names of defined functions. 10 WS FULL
)FNS [LETTER] FUNCTION NAMES 11 NOT GROUPED. NAME IN USE 16
102 List names of global variables. 12 NOT SAVED. WS QUOTA USED UP
)VARB [LETTER] VARIABLE NAMES 13 NOT BAVED. THIB WS IS WSID 16
103 List names of groups. 14 IMPROPER LIBRARY REFERENCE
)GRPB [LETTER] GROUP NAMES 15 MESSAGE LOST 16
104 List membership o:E designa·ted group. 16 INCORRECT COMMAND
)GRP NAME FUNCTION NAMES, VARIABLE NAMES 16
105 List halted functions (state indicator).
)SI SEQUENCE OF HALTED FUNCTIONS 16
106 List ha.l t.ed functions and associated local variables (augmented state indicator).
)SIV SEOUENCE OF HALTED FUNCTIONS WITH NAMES OF LOCAL VARIABLES 16
107 Give identification of active workspace.
)WSID WSID 16
100 List names of workspaces in designated library.
)LIB [NUMBER] NAMES OF STORED WORKSPACES 14 16
109 List ports in use and codes of connected users.
)PORTS PORT NUMBERS AND ASSOCIATED USER CODES 16
IQ10 List port: numbers associated with designated user code.
)PORTS CODE PORT NUMBERS 16
CM1 Address t:ext to designated port.
)MSGN PORT [TEXT] SENT 15 16
CM2 Address text to de s Lqna t ed port, and lock keyboard.
)MSG PORT ['l'EXT] SE NT 15 16
CM3 Address t.ext; to recording terminal (APL Operator).
)OPRN [TEXT]' SENT 15 16
CM4 Address t:ext to zeoo rdd nq terminal (APIJ Operator), and lock keyboard.
)OPR [TEXT] SENT 15 16
Notes: 1. Items in brackets are optional.
2. KEY or LOCK: a password set off from preceding text by a colon.
3. WSID: library number and workspace name, or workspace name alone, as required.
4. See insert table of trouble report forms.
~--------------------------------------------------------'

Table 2.1: SYSTEM COMMANDS

2.7
TERMINAL CONTROL COMMANDS

There is one command for starting a work session, and


there are four commands for ending one. The variations in
ending allow for automatically storing a copy of the active
workspace, and for holding a dial-up telephone connection to
the central computer for an immediate start of another work
session. The starting command has been described in Part 1
(EC3) •
I
FQI'.Q.§g §ng~ng.§. Any action that interrupts a telephone
connection for more than five seconds will cause the work
session to end, and usually cause a copy of the active
workspace to be stored. This provides a safeguard against
loss of work in case of failure in the telephone circuits,
or accidental loss of power at the terminal. It is also the
basis of the gbB.QQDD.§gt action described in EC4 of Part 1.
A work session can also be stopped remotely, from the
system's recording terminal, in an action known as a ~QYD~~.
As in a disconnect, a copy of the active workspace is
usually stored automatically. The bounce may be used when a
port is required for a special purpose, or to clear the
system of all users before stopping the APL\360 operation
completely.

If a work session is ended because of failure of the


central computer, the active workspace is not stored.

Tn§ fQ~!£~QE ~QI'k'§Qgg§. When the active workspace is stored


automatically, as a result of a disconnect, bounce, or one
of the gQn~inY.§ commands described below, it goes into the
user's private library and is given the name CONTINUE. If
the active workspace had a password associated with it,
CONTINUE will be locked with the same password.

If CONTINUE is automatically stored, and is not locked,


it will be automatically activated at the next sign-on;
otherwise, a clear workspace is activated.
Since CONTINUE will replace any workspace that may have
been previously stored under that name, there is a danger
that repeated line failures, while working with a locked
workspace, could lead to a complete loss of information. To
protect against this possibility, a clear workspace is never
stored automatically.

2.8
I.nt~J;:;r;:YJ2t§.g gQtiyitiJ~~§'. An "APL operation in progress at the
moment of occurrence of a bounce or disconnect mayor may
not be carried to its normal conclusion. A defined function
in progress at such a moment will be suspended, but its
p ro qz'e s s can be resumed at a later work session in
accordance with the procedures given in Part 30 A system
command, once begun, will continue to completion regardless
of the state of the terminal.

If a bounce or disconnect occurs when the terminal is


in definition mode, the definition process is arbitrarily
terminated by the system. To proceed with the definition
when CONTINUE is next activated, the definition mode can be
re-established according to the procedures given in Part 3.
The conti.nue commands will be .rej ected in defini t.i.on mode •

.Q~~~9:1:1~.g .Q.~§.9~!E.ti2g. The trouble reports NO SPACE and


LIBRARY TABLE FULL have been omitted from Table 2.1, and are
also omitted from the notes below, because their occurence
is infrequent, and no corrective action can be taken from a
r'emo t e 'terminal. They can arise in response to a continue
command or a .§9:yg command (see section on library control),
and signify t:hat certain of the physical resources of the
system have been exhausted.

Elapsed time or time of day, given as a system


r-e spon ae , is always in hours, minutes, and seconds; two
digits :Eor each, separated by periods. A date response is
given as month, day and year; two digits for each, separated
by slashes. Clock hours are counted continuously from
midnight of the indicated day, and if the system runs past
midnight it is possible to ha.ve time readings we.l L above 24
hours. For example, 340 22 0 00 07 / 11 /68 would bE~ 2 2 minutes
past 10 AM on July 12, 1968.

~~~.!.!. §j;~!,!: §: ~Q!'~ .§§.§.§iQil: See Part 1, EC3.


This 1S the §ign=Qil,
described in EC3 of Part 1.

2.9
~~~~ ~ng ~Q~~ ~~e~!Qn: Passwords longer than eight
Enter )OFF characters are accepted, but
followed by a colon and a only the first eight are
password, if desired. meaningful. Spaces around
the colon are neutral.

~t:!~~t:
1. The currently
workspace will vanish.
active There is no effect on
stored workspace.
any I
2. The duration of the work
session and the amount of
computer time used will be
noted internally for later
accounting.
3. The password, if used, Once applied, a lock stays
will become a new lock on in effect until explicitly
the account number. changed by an ending command
that contains a colon.
An existing lock is removed
if no password follows the
colon.
If a colon is not used, the
existing lock, if any,
remains in force.
4. A dial-up connection to
the central computer will be
broken.

B§§I2QD:§§: l'~Qy1;?!§ ~§12Q~t:


1. The port number, time of INCORRECT COMMAND
day, date, and user code
will be printed on one line.
2. Accounting information The time used in this
will be printed on two session and cumulative time
lines, giving terminal since the last accounting
connection time and central are given in the standard
computer time. format, for both terminal
ti.me and computer time.
The DATA light on telephone
datasets will go out.

2.10
11~~..!. ~~n.Q. :y{Q,~~ §g§§ .!Q~ ~~g See note at TC2.
!J.Q.!g gi:£,:J:=Y1? 9Q!1!}g,g!-.!Q!}:
Enter )OFP HOLD
followed by a colon and a
password, if desired.

~g!~f:!::
1. 2. and 3. Same as for
TC2.
4. The! dial-up telephone An attention signal at this
connection will be time may cause the
maintained for 60 seconds, connection to be broken.
pending a new sign-on.

B§.§w!!.§g: 1'!'QyQ.1§ !'§J2QX.t:


1. and 2. Same as for TC2. INCORRECT COMMAND

~c~..!. End work §§§§.!Q~ ~gQ See note at TC2.


~:!;;Ql;~ --- 9:£~Iy§ ~Q~Js'§2~,g~:
Enter ) CON'lIINUE' A bounce has the same effect
followed by a colon and a and response as this
password, if desired. command. A disconnect has
the same effect, but no
:r.esponse.

~;h~~£:!= :
1. A copy of the currently This effect will not take
active workspace will be place if the active
stored in the user's private workspace is not holding
library with the name information.
CONTINUE. If the workspace
had been activated from a When the workspace is saved
s t.o re d workspace with a it replaces any workspace
lock, the same lock will be previously stored with the
applied to CONTINUE. name CONTINUE.
26 3. and 4. Same as for
TC2.

2.11
B~!H?Qn§g :
1. Time of day and date, This response will be
followed by CONTINUE. omitted if the workspace was
not saved. See note at
Effect 1.
2. and 3. Same as
response 1 and 2.
for TC2, 1'~QY!?1§ ~§2Q~~§:
NOT WITH OPEN DEFINITION
I
means that the terminal is
in definition mode. Close
the definition by entering
the character V. (See
mechanics of function
definition in Part 3.)
INCORRECT COMMAND
I~2~ ~ng ~Q~~ §§§§!QDL See note at TC2.
§tQ~g ~gt!y§ ~Q~~§Qig@L~n~
QQ!g g~~!=gE £Qnng£~!Qn:
Enter )CONTINUE HOLD
followed by a colon and a
password, if desired.

~ff§~t:
1. Same as for TC4.

2. and 3. Same as for TC2.


4. Same as for TC3.

Bg§wn.§g: I~QYQlg ~gW~t§:


1. 2. and 3. Same as for NOT WITH OPEN DEFINITION
TC4. See TC4.
INCORRECT COMMAND

2.12
WORKSPACE CONTROL COMMANDS

The commands in this class can replace the active


workspace with a clear one, or with a copy of a stored
workspace; bring together in the active workspace
information from many stored workspaces; form g~QYQ.§ within
the active workspace; remove unwanted objects from the
active workspace; and set controls governing certain
operations. No conunand in this class affects any but the
active workspace~
The usefulness of a terminal system
bH121iQg.:t:iQD 12sQJs,gg§.§.
is enhanced by the availability of many different
collections of functions and variables, each of which is
o rqan Laed to satisfy the computational needs of some area of
work; :for example, standard stati stical calculations,
exe rcd aes for teaching a scholastic subj ect, complex
azLt.hmecLc , business accounting, text edi ting, etc. The
workspace-cent:ered organization of APL\360 lends itself to
such packaging, because each collection moves as a coherent
unit when the workspace containing it is stored or
acti vat.ed,
The QQgy commands provide a convenient way to assemble
packages from components in different workspaces. The
gJ:Qyg command makes it convenient to have a mul1:iplici ty of
more speciali.zed packages in a single workspace, sharing
common e Lemerrt.s , but available individually by copying the
appropriate group.
G~:Qyg.§. The gJ;,'Qyg command assigns a single name to a
collection of names, in order to provide more convenient
reference to selected functions and global variables. The
group name can subsequently be used fo.!: three purposes: to
move a copy of the entire set of referenced objects between
workspaces, to incorporate the group members wit:hin another
group, and to erase, in a single operation, all objects
re~ferenced by the group. Each of these is further explained
below, in connection with the relevant operation.

InfQJ;,'IDstiQn t~sn.§f§~ ~~t~~~n ~Q~k~pgQ~~. Information


entered or developed within one workspace can be made
available within another by means of the S;:Qgy and
g~~Qt§s;:ti.ng=S;:Qg~ commands, whi ch reproduce within the active
workspace objects from a stored workspace. These are two

2.13
sets of parallel commands which differ only in their
treatment of an object in the active workspace which has the
same name as an object being reproduced: the copy commands
will replace the existing object, whereas the
protecting-copy commands will not make the replacement.
A copy command of either type can be applied to an
entire workspace or to a single object (i.e., a function,
variable, or group). When an entire workspace is copied,
I
all the functions and global variables within it are subject
to the operation, but its index origin and output control
settings, state indicator, and local variables are left
behind.
When a group is copied without protection, both its
definition (i.e., the group name and the collection of names
composing the group), and the objects referenced by the
names within it, are reproduced in the active workspace.
When copied with protection, the group itself, or any of the
objects referenced by its members, will be omitted in order
to protect an object in the active workspace. If the group
definition is successfully copied under these circumstances,
the names composing it will refer to the global objects by
those names in the active workspace, regardless of whether
they were copied' with the group or present before.

-P~.:t:£lj..l~g .P~'§..91;j..PJ:j..9D •
The te rm jj.9..*Js:.§.P£l..9§ j.g~llJ:i-.fi-..9£lJ:j..911 is
used here to mean either a library number followed by a
workspace name, or a workspace name alone. When a name is
used alone, the reference is to the user's private library.
A ~§Y is a colon followed by a password.

F.£:l..! 1\g.:t:i-.Y.fl!:,g This command is used to make


~.9~.5EP§.9,g: a fresh start, discarding
Enter ) CLEAR. whatever is in the active
workspace.

Eii~.9.:t::
1. A clear workspace will be A clear workspace has no
activated, replacing the variables, groups, or
presently active workspace. defined functions.
Its control settings are:
index origin, 1; significant
digits, 10; line width, 120.
Its workspace identification
does not match that of any
stored workspace. (See
section on library control.)

2.14
B.!~§.P.Q n§..§ : ~J:Qubl.e x:.eI2QJ::t
1,. CLEAR WS INCORRECT COMMAND

w~~~.!. b9.!:iy.§.!:g.§ 9Q:QY.Qi .§ This command may be used to


§~~Q.f'~Q. ,~Q.f'1s-'§2E9~: obtain the use of any
Enter )LOAD workspace in "the system
followed by a space and a whose identification (and
workspace identification password) is known.
(with the key, if required).

~~ht~£.!: :
1,. A copy of the designated
workspace will be activated,
replacing the presently
a ct.L ve workspace.

.E§§.PQ!!§g: ~!:Qg!2.!~
I:gJ2Q!:t§
1. SAVED, followed by the WS NOT FOUND
time of day and the date means there is no stored
that the source workspace workspace with the given
wa.s last stored. identification.
WS LOCKED
means that no key, or the
wrong key, was used when one
was required.
INCORRECT COMMAND

N~;;;~.!. ~QJ2Y g. g1Qf?g! QQiggj; A global object may be a


t~Qm g. §tQX~g WQ~~§J2gg§: group, function, or global
Enter )COpy variable.
followed by a space and a
workspace ident£fication When applied to a. group, all
(with the key, if required), copy commands operate both
followed by a space and the on the group definition and
name of the object to be on objects referenced by the
copied. group members.
~;h!'@Q!: :
1. A copy of the designated Members of a group do not
object will appear in the necessarily have referents;
active workspace with global but a group member without a
significance, replacing referent in the source
existing global homonyms. workspace may find one in
the active workspace.

2.15
B§§WD:§§: ~I:QYQlg I:sU2QI::te
1. SAVED, followed by the NOT WITH OPEN DEFINITION
time of day and the date means that the terminal is
that the source workspace in definition mode. Either
was last stored. close the definition by
entering v, or defer the
copy operation.
WS NOT FOUND
See WC2.
I
WS LOCKED
See WC2.
OBJECT NOT FOUND
means that the designated
workspace does not contain a
global object with the given
name.
WS FULL
means that the active
workspace could not contain
all the material requested:
if copied at all, a variable
will be copied completely; a
partially copied function
will leave the terminal in
definition mode; some
objects may be completely
overlooked. Status may be
determined by using appro-
priate inquiry commands.
INCORRECT COMMAND

N~]~.!. ~QJ2Y g1-Q~ii1­ See notes at WC3.


99j.§.9.t§ from .§.:t.Q.r~.Q.
!tQ~5§.P~~~:
Enter )COPY
followed by a space and a
workspace identification
(with the key, if required).

~ti§g.:t.:
1. A copy of all functions, Local variables, the state
groups, and global variables indicator, and settings for
in the source workspace will origin, significant digits,
appear in the active and width are not copied.
workspace with global
significance, replacing
existing global homonymsc

2.16
S~~'§.l?Qn§.~ : ~!:QY12.!g !:~12Q!:j;~
1.. SA VED, followed by the NOT WITH OPEN DEFINITION
time of day and the date WS NOT FOUND
that the source workspace WS LOCKED
was last stored. WS FULL
INCORRECT COMMAND
See We3 for all meanings.

N~;.1..!. ~Q2Y .9 glQQ.9-.! QQj~.Qj; See notes at WC3~


il~QID.9- .§j;Q1:'~g ~Q.r~'§2.§..Q~ ,
21~Q!-§gj;;~ng 1:hg .§..Qj;,iyg
y{~2~Js'§1?f!~g§ :
Enter )PCOpy
followed by a space and a
workspace identification
(with the key, if required) ,
followed by a space and the
name of the object to be
copied.

~]~fg9t :
1., A copy of the designated When a group definition is
object will appear in the copied, any member whose
active workspace unless referent was blocked will,
there is an existin.g global p~rforce, refer to the
homonym. referent of its homonym.

E-sHa12Qil§§ : IJ;:QY121g !:~12Q!:j;§


1., SA VED , followed by the NOT WITH OPEN DEFINITION
time of day and the date WS NOT FOUND
that the source workspace WS LOCKED
was La s t; stored. OBJECT NOT FOUND
WS FULL
2. NOT COPIED:, followed by INCORRECT COMMAND
the names of' objects not See We3 for all meanings.
copied, will be printed if
appropriate.

2.17
WQ~~~ ~QQY gIl glQ~gl See notes at WC3.
QQj~g~§ from ~ §tQ~gg
~Q~~§QgQg, Q~Qtggt~ng thg
gQt!y§ ~Q~~§Q~9~:
Enter )PCOpy
followed by a space and a
workspace identification
(with the key, if required).
I
~ffggt:
1. A copy of all global See note at WC3a, Effect 1.
objects in the source
workspace which do not have See note at WC4, Effect 1.
global homonyms in the
active workspace will appear
in the active workspace.

B§§QQD:§§: . ~~QYQ.!~ ~~QQ~~§


1. SAVED, followed by the NOT WITH OPEN DEFINITION
time of day and the date W8 NO,]; FOUND
that the source workspace WS LOCKED
was last stored. WS FULL
INCORRECT COMMAND
2. NOT COPIED:, followed by See We3 for all meanings.
the names of objects not
copied, will be printed if
appropriate.

2.18
~'~.2.!. ~i9:!:hg!:
9!:QYI2:
Enter )GROUP
followed by a space and one
or more names separated by
spaces.

~~I~,gj;:
1. The first name will be The first name used in the
the name of a group having command must not be the name
the other names as members, of a function or global
subject. to the rules given variable.
in the adjacent notes. An
existing group with the same Any name may be a member of
name wi.ll be superseded. a group; names of groups,
functions, and global
variables, and names without
current global referents are
all acceptable.
Members may be added eto an
existing group by using the
group name twice in the
command: as the first name
and as another.
2. If only one name is used When a group is dispersed
in the command, no group is the group definition is
formed, and an existing destroyed, but the referents
g:coup by 1:hat name is of the group members are
dispersed. unaffected.

~J::QYbl~ ~§I2QJ::.t§:
NOT GROUPED, NAME IN USE
means that the first name
used in the command is the
name of a function or global
variable. Erase the
offending object, or use a
different name.
INCORRECT COMMAND

2.19
~~§~ ~~~~~ g!QQ~! QQj~2~~: This is the only way to
Enter )ERASE remove a global variable,
followed by a space and the and the most convenient way
names of objects to be to remove a collection of
deleted, separated by objects.
spaces.

~f!~£~:
1. Named objects having Names which do not refer to
I
global significance, other global objects are ignored.
than pendent functions, will
be expunged. When a group is erased, both
the group and the referents
of its members are expunged.

B~§I2Q!H~~ : ~~QyQJ:§ !'§.l2Q!,j;:


NOT ERASED:, followed by the INCORRECT COMMAND
names of functions not
erased will be printed, if
appropriate.

N~l~ §~~ ing~~ Q~~g~n iQ~ A dynamically executable


sssss Ql?~.!"B-~i.Qn§·: En ter the equivalent function is
characters )ORIGIN available (see Part 4).
followed by a space and a 0
or 1.

~!!~.9!::
1. First elements of arrays These matters are explained
in the workspace will be in Part 3.
numbered zero or one, as
indicated, and subsequent
use of index-dependent APL
operations will be
appropriately affected •

.B~'§PQD'§~: .1'~Q]J.bl~ .r~:eQ.r.t:


1. WAS, followed by the INCORRECT COMMAND
former origin.

2.20
N~~.e..!. .s§1- IDg~.!IDYID f9£' .§.!g= A dynamically executable
~l!figgnt gig.it.§ .in Qy.tf>Y.t: equivalent function is
Enter )DIGITS available (see Part 4).
followed by a space and an
integer between 1 and 16
inclusive.

~.~f§.9t :
1. Su.bsequent output of This command has no effect
numbers will show no greater on the precision of internal
number of significant digits calculations, whi.ch is
than indicated. approximately 16 decimal
digits.

B!~'§f>Qn.§§ : ~~Qyl;?lg ];§I;?Q.r.t..;


1. WAS, followed by the INCORRECT COMMAND
former maximum.

N!~~..!. .Q§t IDg~iIDYID Y:{.!Q.th fQ~ A dynamically executable


gn QytI2yt .!!n~: equivalent function is
Enter )WIDTH available (see Part 4).
followed by a space and an
integer between 30 and 130
inclusive.

~;hf§.9t :
1. Subsequent output of all This affects neither the
kinds, except messages mechanical margin stops nor
between terminals, will be the allowable length of
limited to a line width no input lines.
greater than the number of
spaces indicated.

.B!~.§I2Qn.§§: 1'~QY12.lS} ~§I2Q£'.t..i.


1. WAS, followed by the INCORRECT COMMAND
former maximum width.

2.21
W~!Q~ ~bgngg ~Q~~~~g£g This command can be used to
!g~!!:t!.f!£E:.t!Q!!: guard against inadvertently
Enter )WSID changing a stored workspace
followed by a space and a that has just been loaded;
workspace identification. and conversely, to enable
the replacement of a stored
workspace without first
using the drop command, when
the active workspace came
I
from a different source.
(See section on library
control commands.)

11i!ig£.:t:
1. The active workspace will See command LCI for the
assume the specified implications of thi.s.
identification. A lock
associated with the
workspace will be retained.

Bg~I2Qn~~: ~':QlJble J:§I2QJ:t:


1. WAS, followed by the INCORRECT COMMAND
former workspace
identification.

LIBRARY CONTROL COMMANDS


There are two basic operations performed by the
commands in this class. The '§2-Y~ commands cause a copy of
an active workspace to be stored in a library, and the g~gp
command causes such a stored copy to be destroyed.
The save commands and the load command are symmetric,
in the sense that a load command destroys an active
workspace by replacing it with a copy of a stored workspace,
while a save command may destroy a stored workspace by
replacing it with a copy of the active workspace.
~9D~J~~i~y91 ~9£~. When a workspace is stored, an exact
copy of the active workspace is made, including the state
indicator and intermediate results from the partial
execution of halted functions. These functions can be
restarted without loss of continuity (see Part 3), which
permits considerable flexibility in planning use of the

2.22
system. For example, lengthy calculations do not have to
be completed at one terminal session; student work can be
conducted over a series of short work periods, to suit class
schedules; and mathematical experimentation or the
exploration of ,system models can be done over long periods
of time, at the investigator's convenience.

lVg.!']5:§P.9:9§ identification. A library number and a name,


together, tin"IqueI"y-identi fy each stored workspace in the
system. An active workspace is also identified by a library
number and a name, and as copies of stored workspaces are
activated, or copies of the active workspace are stored, the
identification of the active workspace may change according
to the following rules:
1.. A workspace activated from a library assumes the
identification of its source.
2. When a copy of the active workspace is stored, the
active workspace assumes the identification assigned to
the stored copy.
3. The library number and name may be arbitrarily
changed by the use of command WelD.
4. A clear worksoace activ.J.ted by a clear command, a
sign-on, or a system failure is called CLEAR WS, which
cannot be the name of a stored workspace.
The ident:ification of active workspaces is used in two
ways. First, as a safeguard against the inadvertent
replacement of a stored workspace by an unrelated one: an
a t t.empt, to replace, by a copy of the active workspace, any
stored workspace other than the one with the same
identification (or the one named CONTINUE), will be stopped.
SE~cond, as a convenience when the active workspace is to be
re-stored with changes: the use of the command )SAVE,
without modification, implicitly uses the identification of
the active workspace.
1;U;?l;'E!l;'Y ~!1g
9-£9Q]Jn.t nYID.Q~X'§. A user's account: number is
also the number of his private library. The numbers of
public libraries range from I to 999, and do not correspond
to any account: number ,
Each stored workspace has implicitly associated with it
the account number signed on at the terminal from which the
save command was entered, and may not be either replaced or
erased, except from a terminal signed on wit:h the same
account number. Thus, a user is prevented from affecting

2.23
the state of another user's private library, or tampering
with public library workspaces which he did not store. He
may, of course, activate a copy of any workspace stored in
the system, if he knows the library number and name (and
password, if required).

§tQ~~g§ g!1Q~m§nt. A user of APL\360 is assigned library


space in terms of the maximum number of stored workspa.ces he
may have at one time. This quota applies to the combined
I
total of workspaces stored either in his private library or
in public libraries. The allotment for each user is
determined by those responsible for the general management
of a particular system, and can be changed from the
recording terminal, as required, within the bounds of the
physical resources of the system.
up to the number in his quota, a user may assign
arbitrary names to the workspaces he stores. Beyond that
point he always has available one workspace named CONTINUE
in his private library.

Y§§ Qf tUg QQNXINQ~ ~Q~~§ggQg. This workspace has the


property that it may be freely replaced by an active
workspace having any identification whatsoever. It is thus
always available as temporary storage, but carries with it
the danger of being easily replaced, as described in the
section on terminal control commands.
The attributes of the CONTINUE workspace are the same
whether stored as a result of a continue command,
disconnect, or bounce, or stored by virtue of a save command
using that name. In the last case, the active workspace
assumes the name CONTINUE, as it would any other name under
like circumstances.

~y~g!gg g ~Q~~~ggg§. The sequence of commands,


)SAVE ABC123, )CLEAR, )COPY ABC123, will purge the active
workspace, clearing it of all but its functions, groups, and
global variables, and reset its controls (see WeI). This
often results in more usable space than can otherwise be
realized. Subsequently, the commands )WSID ABC123 and
)SAVE may be used to store a copy of the purged workspace
under its former name.

2.24
o.e.taile~d D.e.s.c.r..iptian. The term ~oJ:ks.pace. ident.ificat.ion
will be used with the same significance as for the workspace
control commands.

Acrr.I.Q~ NQT.E5.
LC1... Re.=s.tQr:e. a c.QP.}l of the.
ac.tiye. ~Qr:ks~ac.e.:
Enter )SAVE

Effec.t:
1. A copy of the active New workspaces can be stored
workspace will replace the by this command only if the
sco re d workspace with the identification of the active
same identification. workspace has been changed
by WelD.
2. A password associated This forestalls inadvertent
wi th the act.i, ve workspace omission of a lock while
will continue in effect, and actively engaged with a
the stored workspace will be confidential workspace.
locked with this password.

:
R(~s.pa.n.ae TJ:ouble. J:e.porta:
1.. The time of day, date, NOT WITH OPEN DEFINITION
and workspace identification means that the terminal is
will be printed. in function definition mode.
Either close the definition
by entering 'V, or defer the
save operation.
so: SAVED, WS QUOTA USED UP
means that the allotted
number of stored workspaces
has previously been reached.
Unless this is increased,
the workspace can be stored
only by replacing a
workspace already stored.
CONT1NUE may be replaced
di.rectly; any other must be
erased first, or the
identification of the active
workspace must be made to
match by WelD.

2 .. 25
NOT SAVED, THIS WS IS
CLEAR WS
results from the fact that
CLEAR WS.cannot be the name
of a stored workspace.
Either change the name by
WelD, or use Lela. I
IMPROPER LIBRARY REFERENCE
means that an attempt was
made either to replace a
stored workspace that is not
under control of the account
number signed on at the
terminal, or to store into a
non-existent library.
INCORRECT COMMAND

LCla~ Sta~e a CQ~~ af the This form of the save


actiye wQ~kspace: command allows new
Enter )SAVE workspaces to be added to a
followed by a space and a library more conveniently,
workspace identification, and permits locks to be
with a colon and password, added or removed from
if desired. workspaces already present.
Effect:
1. A copy of the active A stored workspace with the
workspace will be stored same identification will be
with the designated replaced.
identification, and with the
assigned lock, if a password A lock on a stored workspace
was used. will not be retained if the
command does not include a
lock explicitly.
2. The active workspace will To this extent only, this
assume the workspace command may affect the state
identification used in the of the active workspace.
command.

2.26
Res.pans.e: Trouble r.:epor.:.ts.:
1. The time of day and date NOT WITH OPEN DEFINITION
will be printed . . means the same as for LCI.
NOT SAVED~ WS QUOTA USED UP
means the same as for LCI.
NOT SAVED~ THIS WS IS
followed by identification
of the active workspace,
means a stored workspace
with the identification used
in the command exists, but
this identification does not
match that of the active
workspace.
IMPROPER LIBRARY REFERENCE
means the same as for LeI.
INCORRECT COMMAND

LC2~ E~ase a stQ~ed WQ~k= Since a key is not used, a


apace : locked workspace whose key
Enter )DROP has been lost can always be
followed by a space and a removed from the system.
workspace identification.
Ej:fect.:
I.. The des i.gna ted stored This command has no effect
workspace will be expunged. on the active workspace,
regardless of its
identification.
RE~SpOns.f~: Tr.:Quble r.:eJ;2Qr.ts.:
1. The time of day and date IMPROPER LIBRARY REFERENCE
will be printed. means that an attempt was
made to drop a workspace
stored by another user.
WS NOT FOUND
means that there is no
stored workspace with the
identification used in the
command.
INCORRECT COMMAND

2.27
INQUIRY COMMANDS

Most of the commands in this class concern the state of


the active workspace. Of the others, one command lists the
names of workspaces in libraries, and two commands are
useful for locating another user at a connected terminal, in
order to communicate with him.

y§§~ gQ9§§. The communication commands described in the


next section require that the port number of the person to
I
be addressed be known. The inquiry commands that provide
this information operate through the device of y§~~ gQg~§,
which serve within the system as partial identification of
users. (The user account numbers, which completely identify
users within the system, are not used for this purpose, and
are treated as private information.) A user code comprises
the first three characters of his name, as it appears in the
sign-on response (Part 1, EC3, Response 2).

A user code is considered to be only partial


identification because it may not be unique. Therefore,
these commands should be used advisedly: before addressing
substantive messages to a terminal which has been identified
by a user code, further confirmation of the receiver's
identity should be sought.

lQl~ ~~§~ n~IDg§ 2! g~!~ngg


!g!1.9~!Q!1§:
Enter )PNS
followed by an alphabetic
character, if desired.

~!f~.91:: None.

,g~'§12Q!1§g: ~~QYQ1§ ~§2Q~j;


1. The names of defined INCORRECT COMMAND
functions in the active
workspace will be printed
alphabetically, starting
with the specified letter.
If a letter was not used,
all function names will be
listed.

2.28
lQ~.s. J:,.!.§.t gsID.§§. Qk glQQg.l
yg.!'.!M.!.§.§:
Enter ) VARS
followed by an alphabetic
character, if desired.

Bg.§12Qg.§§: :I'....QyQ.l~ • .eJ2.Q• .:t


1. The names of global INCORRECT COMMAND
variables in the active
workspace will be printed
alphabetically, starting
with the specified letter Gl

If a letter was not used,


all names of global
variables will be listed.

'!~;2~..t. ~.!'§.t n~m§.§ Q! 9!:QY2§:


Enter )GRPS
followed by an alphabetic
character, if desired.

B~~'§12Qn.§§: ~"QY.Ql~ ;r~l?Q;r.t


1,. The names of groups in INCORRECT COMMAND
the active workspace will be
printed a.lphabetically,
starting with the letter
used. If a letter was not
used, all group names will
be listed.

2.29
!Q1~ ~!§~ ID§mQ§~§b!E Qf
g§§!gn~~§g g~QY2:
Enter )GRP
followed by the name of the
group.
I
g§§l2Q!!§~:
1. The names in the group There will be no response if
will be printed. there is no group with the
designated name in the
active workspace.

~!:QYQJ:§
!:§2Q!:t
INCORRECT COMMAND

.!Q~..!. J:..!§.!: hgl~§g .fg!!g~iQD'§: The line numbers on which


Enter )81 halted functions have
stopped are available for
dynamic use through the
system-dependent functions
I26 and I27. (See Part 3.)

~!i§g~: None •
.B§'§f>Q!1'§~:
1. The names of halted This display is the ~t9~~
functions will be listed, iDgi~~tQ~; its significance
most recent ones first. and use is explained in Part
With each name will be given 3.
the line number on which
execution stopped. Suspend- I!:QyQ.J:§ !:§2Q~t
ed functions will be INCORRECT COMMAND
distinguished from pendent
functions by an asterisk.

2.30
l~Q.Q... ~i.§.t D5!!.t§Q, iY!lQ.ti.QD.§
~.1t.b ngID~'§ Qi lQ.Q.§.l
Y.~1;'.1.9Ql§.§ :
Enter )SIV

;g;.;b.f~.Qt : None ,.
B!~'§I>QD.§g : I~QYQJ:§ ;£§I2Q;£:!;
1. The response will be the INCORRECT COMMAND
same as for lQS, except that
with each function listed
there will appear a listing
o:E its local variables.

1~~1... giy§ ig.s~!1tiii.Qg.tiQn Qi


g~~.tiy§ :~Q1;'Js'§J2'§'.Q§:
Enter )WSID

.B§'§J2Q!1'§,§ : I~QYQJ:§ ~§I2Q~:!;


1 .. The identification of the INCORRECT COMMAND
active workspace will be
printed. The library number
will be included only if it
differs from the account
number associ.ated with the
terminal.

lQ~... ~ig.t !1gID§§ Qf .§tQ~~g A library number is not


N~2.Js;gJ2.a.Q§§ : required for listings of the
Enter )LIB user's private library.
followed, if necessary, by a
library number.

.Bs~'§J2Qn.§g: I~Q!!QJ:§ ~§I2Q~t§


1., The names of workspaces IMPROPER LIBRARY REFERENCE
in the designated library means that an attempt was
will bl~printed.'lf no made to obtain a listing of
number was used, the account another user's private
number associated with the library, or of a
tie rrni.na L will be taken as non-existent library.
the library nu.mber.
INCORRECT COMMAND

2.31
1Q2£ ~~§t gQ~t§ ~ll Y§§ gng
gQg§§ Qb QQnn§Qt§g Y§§1r:g:
Enter )PORTS

B§§2Qll§§:
1. Port numbers in use will
1',t'QY121~
,t',g]2Q.t'.t
INCORRECT COMMAND
I
be printed with the
associated user code.

IQ1Q£ ~~§t gQ~t nYnY2§.§ User codes are not


g§§QQ~gt§g ~~th g§§.ig:: necessarily unique, and the
llgt§9 Y§§I: QQg§: information derived from
Enter )PORTS this command and IQ9 should
followed by the user code. be used advisedly.

;t;ff§g:i;: None.

B§§gQll§g: ~1r:QYl21~ ~~12Q~.t


1. The port numbers of INCORRECT COMMAND
connected users identified
by the code will be printed.

COMMUNICATION COMMANDS
There are two pairs of commands in this class. One
pair addresses any connected terminal, and one pair
addresses only the system recording terminal.

A message can be received by a terminal only when its


keyboard is locked, and except for public address
announcements from the system recording terminal, only if it
is also not in the process of function execution. Hence, to
facilitate two-way communication, one of each pair of
co:nununication conunands results in locking the keyboard of
the sending terminal, pending the receipt of a reply. A
keyboard so locked can be unlocked by an attention signal.

Incoming messages from the system recording terminal


are prefixed by OPR:, and public address messages are
prefixed by PA!:. The latter will interrupt the execution
of defined functions, but the point of suspension will be
printed, and execution can be resumed without loss of
continuity, as explained in Part 3.

2.32
If the interaction at a terminal must be interrupted
for a prolonged period while the terminal is still
connected, it is good practice to lock the keyboard so that
a message may be received. This can be done by addressing a
mes s aqe of 1:he proper type to the terminal's own port
number •

The length of a mes sage is restricted


.Qg,t.fJ.i1'§,9 .Q..§.§.QX],.:Q.ti.QD.
to a single line, not exceeding 120 characters in length.
However, messages are not subject to the width settings of
either the sending or receiving terminal.

~~~1..1. ~~gJ;~'§'§ .!:§Z.t.!:Q g§.§.!g= A message addressed to an


Dg.t'§9 :QQJ;.t: unused or non-existent port
Enter )MSGN will be reflected back to
followed by a port number the sending termi.nal, which
and any one-li.ne text. then plays the role of both
sender and receiver.

Ej~i§.Q,t :
1. The keyboard will lock
while the text is being
transmi t t.e d ,

2. The text will be printed


a t: the recei ving terminal,
prefixed by the port number
of the sending' terminal.

3. The keyboard will unlock


when the transmission is
completed.

.BsL§:QQD.§g : ~J;:QYQl§. J;:§I2Q;t:J;§.


1. SENT MESSAGE LOST
means just that. It happens
when attention is signalled
before a message is
delivered, or an equivalent
transmission disturbance
occurs.

INCORRECT COMMAND

2.33
~M~~ bgg~gEg ~g~~ ~Q gggi9= See note at CMl.
ng~gg RQ~~ gnQ lQ~~ ~gy=
gQg~g:
Enter )MSG
followed by a port number
and anyone-line text.

~ff§~j;;:
I
1. Same as eMl effect 1.
2. Same as CMI, Effect 2,
except for a prefix H, to
indicate that a reply is
awaited.
3. The keyboard will remain The keyboard can be
locked after the response is unlocked, before receiving a
printed. reply, by means of an
attention signal.

B§§QQn§~: ~J;:QYQ!§ ;r§J2QI::~§


1. SENT MESSAGE LOST
See CMl.
INCORRECT COMMAND

~M~~ Agg~§g§ t§~~ ~Q §Yg~§ID See note at CMI.


.§gQ~g~ng ~§~~Ug!:
Enter )OPRN
followed by anyone-line
text.

~ff§gt:
1. 2. and 3. Same as CMl.

B§g12QUg§: ~;rQYQ!§ ;r§2Q;rt§


1. SENT MESSAGE LOST
See CMl.
INCORRECT COMMAND

2.34
~:M1.L 8~lg~§.§ e j;;;§2ft j;;;Q .§Y:§t~HD See note at CMl.
~'§QQ~ging j;§rm!uS!:! gng lQQJs
Js§Y:QQg1~g:
Enter )OPR
followed by any one-line
tiext; ,

~ff§.Qt:
1. 2. and 3. Same as CM2.

E{a~12Qn§ e: r;rQy!2.!§ ;r§12Q;rt§


1. S EN'l' MESSAGE LOST
See CM!.

INCORRECT COMMAND

2.35
I
PART 3

THE LANGUAGE

The APL\360 Terminal System executes system commands or


mathematical statements entered on a terminal typewriter.
The system commands were treated in Part 2; the mathematical
statements will be treated here.
Acceptable statements may employ either ~ I ~ 2
(e.g.
..fJJ.Mj:.j..Q.!'l-S + - x +) which are provided by the system,
o:r .9~.fj.J.l..~...9 ..f.1l.!'l..9..ti..Q-D-S, which the user provides by entering
their definitions on the terminal.
If system commands are not used, the worst that can
possibly result from erroneous use of the keyboard is the
p:rinting of an ~..r.r..Q..r ..r.e.P..Q.z:t. It is therefore advantageous
to experiment freely and to use the system itself for
settling any doubts about its behavior. For example, to
find what happens in an attemped division by zero, simply
enter the expression 4+0. If ever the system seems
unusually slow to respond, execute an attention signal to
interrupt execution and unlock the keyboard.
The Sample Terminal Session of Appendix A shows actual
intercourse with the system which may be used as a model in
gaining facility with the terminal. The examples follow the
t.ext; and may well be studied concurrently. More advanced
programming examples appear in Appendix B.
The primitive functions and the defined functions
available in libraries can be used without knowledge of the
mean s of defining functions. These means are trea ted in the
four contiguous sections beginning with Defined Functions
and ending with Homonyms. These sections may be skipped
without loss of continuity.
FUNDAMENTALS
.sj;.§..1:~.ID~.:g..t~.
Statements are of two main types, the br.an.cb
(denoted by + and treated in the section on Defined
Functions), and the .s:p~..ci.ii..c.ati..on. A typical specification
statement is of the form
X"f-3x4

Thi s st.atemen t; as signs to the y..a..ri...a.,b.l.e X the value re sul t ing


f rom the expression to the right of the .sp.e..ci.fi..c.ati.QD axxo»;

3 .. 1
If the variable name and arrow are omitted, the resulting
value is printed. For example:
3x4
12

Results typed by the system begin at the left margin


whereas entries from the keyboard are automatically
I
indented. The keyboard arrangement is shown in Figure 1.2.
S991~~ 9ng yg~~QL ~Qn~~aD~~. All numbers entered via the
keyboard or typed out by the system are in decimal, either
in conventional form (including a decimal point if
appropriate) or in exponential form. The exponential form
consists of an integer or decimal fraction followed
immediately by the symbol E followed immediately by an
integer. The integer following the E specifies the power of
ten by which the part preceding the E is to be multiplied.
Thus 1n44E2 is equivalent to 144.

Negative numbers are represented by a negative sign


immediately preceding the number, e.g., 1.44 and -144E-2
are equivalent negative numbers. The negative sign can be
used only as part of a constant and is to be distinguished
from the n~g~tiQn function which is denoted, as usual, by
the minus sign -.
A constant vector is entered by typing the constant
components in order, separated by one or more spaces. A
character constant is entered by typing the character
between quotation marks, and a sequence of characters
entered in quotes represents a vector whose successive
components are the characters themselves. Such a vector is
printed by the system as the sequence of characters, with no
enclosing quotes and with no separation of the successive
elements. The quote character itself must be typed in as a
pair of quotes. Thus, the abbreviation of CANNOT is
entered as 'CAN"T' and prints as CAN'T.
NgIDga gnd Spaces. As noted in Part 2, the name of a
variable or defined function may be any sequence of letters
or digits beginning with a letter and not containing a
space~ A letter may be any of the characters A to Z, or any
one of these characters underscored, e.g., d or ~.
Spaces are not required between primitive functions and
constants or variables, or between a succession of primitive
functions, but they may be used if desired. Spaces are
needed to separate names of adjacent defined functions,
constants, and variables. For example, the expression 3+4
may be entered with no spaces, but if F is a defined

3.2

II
function, then the expression 3 F 4 must be entered with the
indicated spaces. The exact number of spaces used in
succession is of no importance and extra spaces may be used
fr_ely ..

Qy~~~t~iking and e~aau~e. Backspacing serves only to


position the carriage and does not cause erasure or deletion
of characters. It can be used:
1. to insert missing characters (such as parentheses)
if space has previously been left for them,
2. to form compound characters by overstriking (e.g.
<P and ! ) , and
3. to position the carriage for erasure, which is
effected by striking the linef.eed (marked ,ATTN on IBM
2741 terminals). The linefeed has the effect of
erasing the character at the position of the carriage,
and all characters to the right.

~qq Qf a~qt~m~u~. The end of a statement is indicated by


striking the carriage return (followed, on some terminals,
by an explicit transmission signal as described in Part 1).
The typed entry is then interpreted ~a..c..t.l.:¥. as it appears on
the page, regardless of the time sequence in which the
charact:ers were typed.

~~g§~ 91§~§9g~j9n. In a compound expression such as


3 x4+6+2, the functions are executed (evaluated) from
rightmost to leftmost, regardless of the particular
functions appearing in the expression. (The foregoing
expression evaluates to 21.) When parentheses are used, as
in the expression W+( SfQ )+XxY,-Z, the same rule applies, but,
as usual, an enclosed expression must be completely
evaluated before its results can be used. Thus, the
foregoing expression is equivalent to W+ ( 3 f Q ) + (Xx ( Y - Z ) ) •
In general, the rule can be expressed as follows: every
function takes as its righthand argument the entire
expression to its right, up to the right parenthesis of the
pair that encloses it.

E~£g£ 1~P9£~§. The attempt to execute an invalid statement


will cause one of the error reports of Table 3.1 to be typed
out. The error report will be followed by the offending
s t.a t ernerit; with a caret typed under the point in the
statement where the error was detected. If the caret lies
to the right of a specification arrow, the specification has
not yet: been performed.

3.3
TYPE Cause; CORRECTIVE ACTION

CHARACTER Illeqitimate overstrike.

DEPTH Excessive depth of function execution. CLEAR STATE


INDICATOR.

DOMAIN
DEFN
Arguments not in the domain of the function.

Misuse of V or 0 symbols:
I
1. V is in some position other than the first.
2. The function is pendent. DISPLAY STATE
INDICATOR AND CLEAR AS REQUIFED.
3. Use of other than the function name alone in
reopeninq a definition.
4. Improper request for a line edit or display.

INDEX Index value out of range.

LABEL Name of already defined function used as a label,


or colon used other than in function definition
and between label and statement.

LENGTH Shapes not conformable.

RANK Ranks not conformable.

RESEND Transmission failure. RE-ENTER. IF CHRONIC,


REDIAL OR HAVE TERMINAL OR PHONE REPAIRED.

SYNTAX Invalid syntax; e.g., two variables juxtaposed;


function used without appropriate arguments as
dictated by its header; unmatched parentheses.

SYMBOL Too many names used. ERASE SOME FUNCTIONS


TABLE OR VARIABLES, THEN SAVE, CLEAR, AND COPY.
FULL
SYSTEM Fault in internal o2eration of APL\ 360. RELOAD
OR SAVE, CLEAR, AND COPY. SEND TYPED RECORD,
INCLUDING ALL WORK LEADING TO THE ERROR, TO THE
SYSTEM MANAGER.

VALUE Use of name which has not been assigned a value.


ASSIGN A VALUE TO THE VARIABLE, OR DEFINE THE
FUNCTION.

WS FULL Workspace is filled (perhaps by temporary values


produced in evaluating a compound expression).
CLEAR STATE !NDICATOR, ERASE NEEDLESS OBJECTS, OR
REVISE CALCUlATIONS TO USE LESS SPACE.

Table 3.1 ERROR REPORTS

3.4
If an invalid statement is encountered during execution
of a defined function, the error report includes the
function name and the line number of the invali.d statement.
The recommended procedure at this point is to enter a right
arrow (-+) alone, and then retry with an amended statement.
'I~he matter is treated more fully in the section on Suspended
Function Execution.

!:if.9IDg.§ Qf. l:?J;'.!ID.!.t.!Y~ iYDQ.tiQD..s. The pr imi tive func tion s of


t.he language are summarized in Tables 3.2 and 3.8, and will
be discussed individually in subsequent sections. The tables
show one suggested name for each function. This is not
i.ntended to discourage the common mathematical practice of
vocalizing a function in a variety of ways (for example,
XfY may be expressed as "X divided by Y", or "X over Y").
Thus, t:he expression pM yields the gim.en.siQD of the array M,
but the terms .§.!1i,§ or .§Dgl:?S: may be preferred both for their
brevity and for the fact that they avoid potential confusion
wi, th the g4:IDgn'§.!Qng.l.!.t~ or l::gnk of the array.

The importance of such names and synonyms diminishes


with familiarity. The usual tendency is toward the use of
the name of the symbol itself (e.g., "rho" (p) for "size",
and "i.ota" (1) for "index generator U ) , probably to avoid
unwanted connotations of any of the chosen names.
SCALAR FUNCTIONS
Each of the primitive functions is classified as either
.§g~l~r or ID.!~g9. Scalar functions are defined on scalar
(i. e., indi vidual) arguments and are ex t end ed to arrays in
four ways: element-by-element, reduction, inner product, and
outer product, as described in the section on Functions on
Arrays. Mixed functions are discussed in a later section.

The scalar functions are summarized in Table 3.2. Each


is def ined on real numbers or " as in the cas e of the log ical
functions gng and Q~, on some subset of them. No functional
distinction is made between "fixed point" and "floating
po i.nt;" numbers, this being primarily a ma tce r of the
representation in a particular medium, and the user of the
berminal system need have no concern with such questions
unless his work strains the capacity of the machine with
respect to either space or accuracy.
Three different representations for numbers are used
internally, and transformations among them are carried out
automatically~ Integers less than 2 to the power 52 are
carried with full pr-ec Ls Lo nr larger numbers and non-integers
are carried to a pr:ecision of about 16 decimal digits.

3.5
I
Monadic form fB f Dyadic form AfB
Definition Name Name Definition
or example or example

«B +~ O+B Plus + Plus 2 + 3 0 2 +-.+ 5. 2

·-B +-~ O-B Negative Minus 2-3.2+--+ 1.2

xB +~ (B>O)-(B<O) Signum x Times 2x3.2 +~ 6.4

~~B +~ 1 sB Reciprocal Divide 2f3.2 +-+ 0.625

Ceiling r Maximum 3r7 +~ 7

Floor L Minimum 3L7 +~ 3

*B +~ (2.71828. o)*B Exponential * Power 2*3 +~ 8

Natural fi Logarithm A$B +~ Log B base A


logarithm A$B +~ ($B)ffiA

1-3014 +~ 3 01.4 Magnitude I Residue Case AlB


A~O B-( IA)xLBfIA
A=O,B~O B
A=O,B<O Domain error

! 0 +-+ 1 Factorial , Binomial A!B +~ (!B)f( !A)x!B-A


:!B +~ Bx!B-1 coef ficient 2 ! 5 +~ 10 3!5 +~ 10
or !B +~ Gamma(B+1)

:?B +~ Random choice Roll ? Deal A Mixed Function (See


from tB Table 3.8)

oB +~ BX3.14:l.59. o. pi times 0 Circular See Table at left

'''1 +~ 0 ""'0 +~1 Not ,...,

A And A B AAB AVB A'fo<B A¥B


(-A )oB A AoB v Or 0 0 0 0 1 1
(1-B*2)*0~) 0 (1-B*2)*05 'fo< Nand 0 1 0 1 1 0
Arcsin 13 1 Sine B ¥ Nor 1 0 0 1 1 0
Arccos 13 2 Cosine B 1 1 1 1 0 0
Arct.an 13 3 Tangent B
(-1+B*2)*0~) 4 (1+B*2)*05 < Less Relations
Arcsinh 13 5 Sinh B s Not greater Result is 1 if the
Arcco ah 13 6 Cosh B = Equal relation holds, 0
.Arctanh B 7 Tanh B ~ Not less if it does not:
> Greater 3~7 1 +~

Table of Dyadic 0 Functions ~ Not Equal 7~3 0 +~

Table 3.2: PRIMITIVE SCALAR FUNCTIONS

3.7
For operations such as floor and ceiling, and in
comparisons, a "fuzz" of about 1E-13 is applied in order to
avoid anomalous results that might otherwise be engendered
by doing decimal arithmetic on a binary machine.
Two of the functions of Table 3.2, the relations ~ and
= are defined on characters as well as on numbers.

MQn~~iQ ~n~ ~Y~~iQ f~nQtiQns. Each of the functions defined


in Table 3.2 may be used in the same manner as the familiar
I
arithmetic functions + - x and •• Most of the symbols
employed may denote either a mQuadiQ function (which takes
one argument) or a dyadiQ function (which takes two
arguments). For example, fY denotes the monadic function
£~ilinq applied to the single argument Y, and Xry denotes
the dyadic function ma~imum applied to the two arguments X
and Y. Any such symbol always denotes a dyadic function if
possible, i.e., it will take a left argument if one is
present.
At this point it may be helpful to scrutinize each of
the functions of Table 3.2 and to work out some examples of
each, either by hand or on a terminal. However, it is not
essential to grasp all of the more advanced mathematical
functions (such as the hyperbolic functions sinh, cosh, and
tanh, or the extension of the factorial to non-integer
arguments) in order to prooeed , Treatments of these
functions are readily available in standard texts.

Certain of the scalar functjons deserve brief comment.


The ~g~idye function AlB has the usual definition of residue
used in number theory. For positive integer arguments this
is equivalent to the remainder obtained on dividing B by A,
and may be stated more generally as the smallest
non-negative member of the set B-NxA, where N is any
integer.

This formulation covers the case of a zero left


arqument as shown in Table 3.2. The conventional definition
is extended in two further respects:

1. The left argument A need not be positive; however,


the value of the result depends only on the magnitude
of A.

2. The arguments need not be integral. For example,


112.6 is 0 and 1.518 is 0.5.
06

The expression 8*05 (square root of -8) yields a


domain error, but -8*1+3 has the value 2. More generally,
A*B is valid for A<O if the right argument is (a close
approximation to) a rational number with an odd denominator
not greater than 85.

3.8
The factorial function !N is defined in the usual way
as the product of the first N positive integers. It is also
extended to non-integer values of the a rq ument; N and is
equivalent to the Gamma function of N+1.
The function A!B (pronounced A out of B) is defined as
(!B)t(!A)x!B-A. For integer values of A and B, this is the
number of combinations of B things taken A at a time. (It
is related t.o the Complete Beta function as follows:
Beta(P,Q) ++ +Qx(P-1)!P+Q-1.)

The symbols < s = ~ > and ~ denote the relations


!g§§ ~hAn, !g§§ tbAn Q~ ~gY~l, etc., in the usual manner.
However, an expression of the form A<B is treated not as an
assertion, but as a function which yields a 1 if the
proposition is true, and 0 if it is false. For example:
3s7
1

When applied to lQgiQgl arguments (i.e., arguments


whose values a.re limited to 0 and 1), the six relations are
equivalent to six of the logical functions of two arguments.
For example, s is equivalent to mg:t~;r.igl .i.mgliQatiQD, and ~
is equivalent to ~~Qly§iY§-Q~. These six functions together
with the gng, Q~, n9:ng, and nQ!': shown in Table 3.2 exhaust
the nontrivial logical functions of two loqical arquments.
y~§g!;;Q;r§.
Each of the monadic functions of Table 3.2 applies
to a vector, element by element. Each of the dyadic
functions applies element by element to a pair of vectors of
equal dimension or to one scalar and a vector of any
dimension, the scalar being used with each component of the
vec t.or , For examp Le r

1 2 3 4>( 4 3 2 1
4 6 6 4
2+1 2 3 4
3 4 5 6
1 2 3 4["2
2 2 3 4

I~~~~ g~n~~9:!;;Q~. If N is a non-negative integer, then 1N


denotes a vector of the first N integers. The dimension of
the vector 1N is therefore N; in particular, 11 is a vector
of length one which has the value 1, and 10 is a vector of

3.9
dimension zero, also called an Slm12t~ vector. The empty
vector prints as a blank. For example:

14
1 2 3 4

1 2
15
3
10
4 5 I
Empty vector prints as a blank
6-16
5 4 3 2 1 0
2 X10 Scalar applies to all (i.e., 0) elements
of 10, resulting in an empty vector
2 X16
2 4 6 8 10 12

The index generator is one of the class of mixed


functions to be treated in detail later; it is included here
because it is useful in examples.
DEFINED FUNCTIONS

~~~~Qg~£~~Q~. It would be impracticable and confusing to


attempt to include as pri.mi.t.Lve s in a language all of the
functions which might prove useful in diverse areas of
application. On the other hand, in any particular
application there are many functions of general utility
whose use should be made as convenient as possible. This
need is met by the ability to define and name new functions,
which can then be used with the convenience of primitives.
This section introduces the basic notions of function
definition and illustrates the use of defined functions.
Most of the detailed mechanics of function definition,
revision, and display, are deferred to the succeeding
section.
The sequence
\JSPHERE
[1J SURF+4x3.14159xRxR
[2J VOL+SURFxRf3
[3J \J

is called a f~~~t~Q~ ~~t~Q~ti~u; the first \J (pronounced


q~l) marks the beginning of the definition and the second \J
marks the conclusion: the name following the first V (in
this case SPHERm is the name of the function defined, the
numbers in brackets are ~~~~~m~Q~ ~umQe~a, and the
accompanying statements form the QQ~ of the function
definition.

3.10
The act of defining a function neither executes nor
checks for validity the statements in the body; what it does
is make the function name thereafter equivalent to the body.
For example:

\/SPHERE Definition of the


[ 1] SURF+4x3014159xRxR function SPHERE
[ 2] T/OL+S URPxR+ 3
[ 3] \J
R+2 Specification and display
R of the argument R
2
SURF SURF has not been
VALUE ERROR assigned a value
SURF
II,
SPHERE Execution of SPHERE
SURF SURF and VOL now have
50 02654.4 values assigned by the
T/OL execution of-SPHERE
33051029333
11'+1 Use of SPHERE for
SPHERE a new value of the
SURF argument R
12 056636

T/OL
4 0188786667

~'.!'~'!}9.£1i:D:g.
Statements in a function are normally executed
in the order indicated by the statement numbers, and
executi.on terminates at the end of the last statement in the
sequence. This normal order can be modified by 1>.r.§.D.QD§.§.
Branches make possible the construction of iterative
procedures.
The expression -+4 denotes a 1>!,gD.Q.D to statement 4 and
causes statement 4 of the function to be executed next. In
general, the arrow may be followed by any expression which,
t.o be effective, must evaluate to an integer. This value is
t.he number of the statement to be executed next. If the
integer lies outside the range of statement numbers of the
body of the function, the branch ends the execution of the
function.
If the value of the expression to the right of a branch
a.rrow i.s a non-empty vector, the branch is determined by its
first component. If the vector is empty (i.e., of zero
dimension) the branch is vacuous and the normal sequence is
followed.

3.11
The following examples illustrate various methods of
branching used in three equivalent functions (SUM, SUM1, and
SUM2) for determining S as the sum of the first N integers:

[1J
[ 2J
VSUM
S+O
I+1
I
[ 3J -+4xI$.N Branch to 4x1 (i.e., 4) or to 4xO (out)
[ 4J S+S+I
[5J I+I+1
[ 6J -+3 Unconditional branch to 3
[7J V
N+1
SUM
S
1
N+2
SUM
S
3
N+5
SUM
S
15
VSUMl Equivalent to SUM
[1J S+O
[ 2J I+1
[ 3J -+OxlI>N Branch to O(out) or continue to next
[4J S+S+I line since OX10 is an empty vector
[ 5J I+I+1
[6J -+3 Unconditional branch to 3
[7J V
N+5
SUM1
S
15
VSUM2 Equivalent to SUM
[ 1J S+O
[2J I+O
[3J S+S+I
[4J I+I+1
[ 5J -+3 X1I$.N Branch to 3 or fall through(and out)
[6J V

From the last two functions in the foregoing example,


it should be clear that the expression Xl occurring in a
branch may often be read as "if". For example, -+3 X1I$.N may
be read as "Branch to 3 if I is less than or equal to N."

3.12
bgg.@-.!
.@-1]..9 g.!QR.§.! Y'@-1'..!£l!?]..§1§. A variable is nonnally g1Q!?.£l1
in the sense that its name has the same significance no
matter what function or functions it may be used in.
However, the iteration counter I occurring in the foregoing
function 8UM is of interest only during execution of the
function; it is frequently convenient to make such a
variable 19.Q.§.1.:t:Q £1 iYD.Q.:t:..!.Q.D in the sense that it has
meaning only during the execution of the function and bears
no relation to any object referred to by the same name at
o·ther times. Any number of variables can be made local to a
function by appending each (preceded by a semicolon) to the
function header. Compare the following behavior of the
function 8UM3, which has a local variable I, with the
behavior of the function 8UM2 in which I is global:
'l/8UM3 ;I 'l/8UM2

[:1J 8+-0 [1J 8+0


[:2J T+O [ 2J I+O
[ :3 J 8+8+I [3J 8+8+I
[ 1Lj. J I+I+1 [ 4J I+I+1
[ !S J -+3X1I~N [ 5J -+3X1I~N
[I5J '1/ [6J '1/
T+20 I+20
N+-5 N+5
8UM3 8UM2
8 8
15
I I
20

Since I is local to the function 8UM3, execution of 8UM3 has


no effect on the variable I referred to before and after the
use of 8UM3.
However, if the variable X is local to a function F
then any function G used within F may refer to the same
variable X, unless the name K is further localized by being
made local to G. For further treatment of this matter, see
the section on Homonyms.

3.13
~~El!£!~ ~fgYm§nt. A function definition of the form
'IlSPH X
[ 1J SUR+4x3 014159xXxX

[2J 'Il

defines SPH as a function with an explicit argument;


I
whenever such a function is used it must be provided with an
argument. For example:

SPH 2
SUR
50n 26544
SPH 1
SUR
12056636

Any explicit argument of a function is automatically


made local to the function; if E is any expression, then the
effect of SPH E is to assign to the local variable X the
value of the expression E and then execute the body of the
function SPHo Except for having a value assigned initially,
the argument variable is treated as any other local variable
and, in particular, may be respecified within the function.

~~E!!2!~ ~~§~l~. Each of the primitive functions produces a


result and may therefore appear within compound expressions.
For example, the expression fZ produces an explicit result
and may therefore appear in a compound expression such as
X+fZ o A function definition of the form

'IlZ+SP X
[lJ Z+4x3014159xXxX
[2J 'Il

defines SP as a function with an explicit result; the


variable Z is local, and the value it assumes at the
completion of execution of the body of the function is the
explicit result of the function. For example:

Q+3 xSP 1
Q
37~ 69908
R+2
(SP R)xRf3
33.51029333

3.14
T.D§ !QI'ID§ Q! 9§tiD§Q, tYD.Q!;.!QDR. Functions may be defined
with 2,1, or 0 explicit arguments and either with or without
an explicit result. The form of header used to define each
of these six types is shown in Table 3.3. Each of the six
forms permits the appena.1.ng of semicolons and names to
introduce local variables. The names appearing in anyone
header must all be distinct; e.g., the· header Z+F Z is
invalid.

Number of Number of Results


Arguments 0 1

0 VF VZ+F
1 VF Y VZ+F Y
2 VX F Y VZ+X F Y
Table 3.3: FORMS OF DEFINED
FUNCTIONS

It is not obligatory either for the arguments of a


defined function to be used within the body, or for the
result variable to be specified. A function definition
which does not assign a value to the result variable will
engender a Ys!Y§ g~~Q~ report when it is used within a
compound expression. This behavior permits a function to be
defined with a restricted domain, by testing the argument(s)
and branching out in certain cases without specifying a
ze suI t. For example:
VZ+SQRT X
[1J -+OXlX<O
[2J Z+X*o5V
Q+SQRT 16
Q
4
Q+SQRT 16
VA.LUE ERROR
Q+SQRT 16
A

3.15
Q§§ QI g§!~n§g !yngtiQng. A defined function may be used in
the same ways that a primitive function may. In particular,
it may be used within the definition of another function.
For example, the function HYP determines the hypotenuse of a
right triangle of sides A and B by using the square root
function SQRT:
VZ+SQRT X
I
[1J Z+X*o5V
VH+A HYP B
[1J H+SQRT (A*2)+B*2V
5 HYP 12
13

A defined function must be used with the same number of


arguments as appear in its header.

B§gg~~iy§ fYngt~Qn g§finitiQn£ A function F may be used in


the body of its own definition, in which case the function
is said to be ~§£Y~~~Y§ly defined. The following program
FAC shows a recursive definition of the factorial function.
The heart of the definition is statement 2, which determines
factorial N as the product of Nand FAC N-1, except for the
case N=O when it is determined (by statement 4) as 1:
VZ+FAC N
[1J +4 X 1 N = 0
[2J Z+NxFAC N-1
[3J +0
[ 4J Z+1 V

~~~g§ £Qnt~Q!. A t~gg§ is an automatic type-out of


information generated by the execution of a function as it
progresses. In a complete trace of a function P, the number
of each statement executed is typed out in brackets,
preceded by the function name P and followed by the final
value produced by the statement. The trace 1S useful in
analyzing the behavior of a defined function, particularly
during its design.

The tracing of P is controlled by the t~gQ§ Y§QtQ~ for


P, denoted by T~P. If one types T~P+2 3 5 then statements
2,3,and 5 will be traced in any subsequent execution of P.
More generally, the value assigned to the trace vector may
be any vector of integers. Typing T~P+O will discontinue
tracing of P. A complete trace of P is set up by entering
T~P+1N, where N is the number of statements in P.

3.16
MECHANICS OF FUNCTION DEFINITION

When a function definition is opened (by typing a V


followed by a header), the system automatically types
successive statement numbers enclosed in brackets and
accepts successive entries as the statements forming the
body of the definition. The system is therefore said to be
in g~~j~i~iQD mode, as opposed to the ~X~~~iQD mode which
prevails outside of function definition.

There are several devices which may be used during


function definition to revise and display the function being
defined. After function definition has been closed, there
are convenient ways to re-open the definition so that these
same devices may be used for further revision or display.

~@~§J§., If a statement occurring in the body of a function


definit:ion is prefaced by a name and a colon, then at the
end of the definition the name is assigned a value equal to
t.he sta tement number. A variable spec if ied in this way is
called a J,g...b.el. Labels are used to advantage in branches
when it is expected that a function definition may be
changed for one reason or another, since a label
a.utomat:ically assumes the new value of the statement number
of its associated statement as statements are inserted or
deleted •

.E.~.Y.i.s.i.Q.D.
Any statement number (including one typed by the
system) can be overridden by typing [N], where N is any
positive number less than 10000, with or without a decimal
point and with at most four digits to the right of the
decimal point. If N is zero, it refers to the header line
of the function.

If any statement number is repeated, the statement


following it supersedes the earlier specification of the
statement. If any s t.a t.emerit; is empty t.hat is, the
bracketed statement number was immediately followed by both
a linefeed and a carriage return (a carriage return alone is
vacuous) -- it is deleted.

When the function definition mode is ended, the


statements are reordered according to their statement
numbers and the statement numbers are replaced by the
integers 1,2,3, and so on. Labels are assigned appropriate
values.

3.17
The particular statement on which the closing V appears
is not significant, since it marks only the end of the
definition mode, not necessarily the last line of the
function. Moreover, the closing V may be entered either
alone or at the end of a statement.
Qi.§:gl§:l.During function definition, statement N can be
displayed by overriding the line number with [ND]o After
I
the display, the system awaits replacement of statement N.
Typing [OJ displays the entire function, including the
header and the opening and closing v, and awaits entry of
the next statement; typing [ON] displays all statements from
N onward and awaits replacement of the last statement.
Executing an attention signal will stop any display.
Lin§ §giting. During function definition, statement N can
be modified by the following mechanism:
4!1
1. Type [NOM] where M is an integer.
2. Statement N is automatically displayed and the
carriage stops under position M.
3. A letter or decimal digit or the symbol/may be
typed under any of the positions in the displayed
statement. Any other characters typed in this mode
are ignored. The ordinary rules for backspace and
linefeed apply.
4. When the carriage is returned, statement N is
re-displayed. Each character understruck by a / is
deleted, each character understruck by a digit K is
preceded by K added spaces, and each character
understruck by a letter is preceded by 5xR spaces,
where R is the rank of the letter in the alphabet.
Finally, the carriage moves to the first injected
space and awaits the typing of modifications to the
statement in the usual manne~. The final effect is to
define the statement exactly as if the entry had been
made entirely from the keyboard; in particular, a
completely blank sequence leaves the statement
unchanged.
If the statement number itself is changed during the
editing procedure, the statement affected is determined by
the new statement number; hence statement N remains
unchanged. This permits statements to be moved, with or
without modification.

3.18
~J~.Q.P§llj.D..g
.f.Y.D.9J:i..Q,D ..Q...e.f..iDl..t.i.o.D. If a function R is already
defined, the definition mode for that function can be
re-established by entering VR alone: the rest of the
f unct.Lori header must not be entered. The system responds by
typing [N+1J, where N is the number of statements in R.
Function definition then proceeds in the normal manner.

Function definition may also be established with


editing or display requested on the same line. For example,
VR[S]X+X+1 initiates editing by entering a new line 3
immediately. The system responds by typing [4J and awaiting
continuation. The entire process may be accomplished on a
single line. Thus, VR[S]X+X+1V opens the definition of R,
enters a new line 3, and terminates the definition mode.
Also, IJR[DJv causes the entire definition of R to be
displayed, after which the system returns to execution mode.

Similar expressions involving display are also


permissible, for example, VR[[]S]V or VR[DJ or VR[2D10].

~g.9ls:~g
J.YD..Q.t..!.9D...6. I f the symbol 'iii' (formed by a V over struck
with a - and called del-tilde) is used instead of V to open
or close a function definition, the function becomes ~Q.c.ke..d.
A locked function cannot be revised or displayed in any way.
Moreover, an error stop within the function will print only
the function name and statement number, not the statement.
Finally, the associated stop control (see next section) and
trace control vectors cannot be changed after the function
is Lo cked ,

Locked functions are used to keep a function definition


proprietary. For example, in an exercise in which a student
is required to determine the behavior of a function by using
it for a variety of arguments, locking a function prevents
him from displaying its definition.

~~l~~iQD 9f fYn~tiQD~ 9D~ ygriab~..e~. A function F (whether


locked or not) is deleted by the command )ERASE F (see Table
2.1). It may also be deleted by deleting every one of its
statements. A variable may be deleted only by the erase
command.

~YB~~ID .9QIDIDsDg ~Dter..eg guxing iYn~tiQD ~efini~iQD. A system


command entered during function definition will not be
accepted as a statement in the definition. Some commands,
such as )COPY, will be rejected with the message
NOT WITH OPEN DEFINITION (see Table 2.1): most will be
execut.ed immediately.

3.19
SUSPENDED FUNCTION EXECUTION

Sy~pgn~iQn. The execution of a function F may be stopped


before completion in a variety of ways: by an error report,
by an attention signal, or by the stop control vector S~F
treated below. In any case, the function is still active
and its execution can later be resumed.
function is said to be ~U§9~Dge~.
In this state the
Typing +K will cause
I
execution of the suspended function to be resumed, beginning
with statement K.

Whatever the reason for suspension, the statement or


statement number displayed is the next one to have been
executed. A branch to that statement number will cause
normal continuation of the function execution, and a branch
out (+0) will terminate execution of the function.

The function r26 (described in the sedtion on System


Dependent Functions) yields the number of the statement next
to be executed. Hence the expression +r26 provides a safe
and convenient way to cause normal resumption of execution.
In the suspended state all normal activities are
possible. In particular, the system is in a condition to:
1. execute statements or system commands.
2. resume execution of the function at an arbitrary
point N (by entering ~N).
3. reopen the definition of any function which is not
g§ng§nt. The term ~enQent is defined in the
discussion of the state indicator below.
If function execution is interrupted by a disconnect,
the function is suspended and the resulting active workspace
is automatically saved under the name CONTINUE, as noted in
Part 2.

St~t§ 1n~ig~tQ~. Typing lSI causes a display of the state


bngbggtQ~; a typical display has the following form:
lSI
H[7] *
G[2]
F[3]

The foregoing display indicates that execution was


halted just before executing statement 7 of the function H,

3.20
that the current use of funct.ion H was invoked in statement
2 of function G, and that the use of function G was in turn
invoked in statement 3 of F. The * appearing to the right
of H[7] indicates that the function H is suspended; the
functions G and F are said to be Rendent.

Further functions can be invoked when in the suspended


state. Thus if G were now invoked and a further suspension
occurred in statement 5 of Q, itself invoked in statement 8
of G, a subsequent display of the state indicator would
appear as follows:
)SI
Q[5] *
G[S]
H[7] *
G[2]
F [3]

The entire sequence from the last to the preceding


suspension can be cleared by typing a branch with no
argument (that is, -+). This behavior is illustrated by
continuing the foregoing example as follows:

)8I
H[ 7] *
G[2]
F[3]

Rap eat.e d use of -+ will clear the state indicator completely.


The cleared state indicator displays as a blank line.

~!.QI? ~Q'!}.t.!'.Q!.
The §.tQI? Y§.Q.:t:QX for a function P is denoted
by S~P. It is set in the same manner as the trace vector
(i.e., by S~P~-I, where the vector I specifies the numbers of
the statements controlled), and stops execution just 1?~.f.QX§
each of the specified statements. At each stop, the
function name and the line number of the statement next to
be executed are printed. After the stop the system is in
the normal suspended state; resumption of execution may
therefore be initiated by a branch.

Trace control and stop control can be used in


conjunction. Moreover, either of the control vectors may
be set within functions. In particular, they may be set by
expressions which initiate tracing or halts only for certain
values of certain variables.

3.21
HOMONYMS

Y~£i~Ql~ ngID@§. The use of local variables introduces the


possibility of having more than one object in a workspace
with the same name. Confusion is avoided by the following
rule: when a function is executed, its local variables
supersede, for the duration of the execution, other objects
of the same name. A name may, therefore, be said to have
I
one g9~iyg referent and (possibly) several 19t~Dt referents.
The complete set of referents of a name can be
determined with the aid of the SIV list (state indicator
with local variables), whose display is initiated by the
command )SIV. The SIV list contains the information
provided by the command )SI, augmented by the names of the
variables local to each function. A sample display follows:
)SIV
G[7J * z X I
F[4J P J
Q[3] * c X T
R[2] P
G[3J z X I
If the SIV list is scanned downward, from the top, the
first occurrence of a variable is the point at which its
active referent was introduced; lower occurrences are the
points at which currently latent referents were introduced;
and if the name is not found at all, its referent is global,
and should be sought for with the commands ) F NS, ) VAR 5', or
)GRPS.

As the state indicator is cleared (by +, or by the


continuation to completion of halted functions), latent
referents become active in the sequence summarized, for the
preceding SIV list, by the following diagram:

z X I P J C T A B
G -t -t -t I I I I I I
F I I I -t -t I I I I
Q I -t I I I -t -t I I
R I I I -t I I I I I
G -t -t -t I I I I I I
Global -t -t -t -t -t -t -t -t -t

The currently active referent of a name holds down to


and including the execution of the function listed at the
point of the first arrow, because of localization of the

3.22
name w i.t.hf.n tha.t function. The first latent referent
becomes active when that function is completed, and holds
down t.o the next arrow; and so forth until the state
Lnd i.cat.o r is completely cleared, at which point there are no
longer any latent referents, and all active referents are
global objects.

Function g~ID§'§. All function names are global. In the


foregoIng example, therefore, a function named P cannot be
used within the function R or within any of the functions
ernp Loy ed by R, since the local variable name P makes the
function P inaccessible. However, even in such
circumstances, the openinq of function definition for such a
function P is possible. (Moreover, as stated in Part 2,
system commands concern global objects only, regardless of
the current environment.)

This scheme of homonyms is easy to use and relatively


free from p i.t.f a Ll s , It can, however, lead to seeming
anomalies as indicated bv the followinq example (shown to
the aut.ho zs by J. C. Shaw) of two pairs of functions which
differ only in the name used for the arqument:
k.!.'
VZ+E X VZ+F J{
[1J Z+X+YV [ :J. J Z+X'+~V
'\ <
VZ+G ,y(;.'\ VZ+GR 'i
[1J Z+F YV [1J Z+Y RV
Y+3 Y+3
G 4 G 4'
8 7

INPUT AND OUTPUT

The following function determines the value of an


amount A invested at interest B[1J for a period of B [2 J
years:
VZ+A CPI B
[1J Z+Ax(1+o01 xB[1J)*B[2JV

For example:
1000 CPI 5 4
1215050625

3.23
The casual user of such a function might, however, find
it onerous to remember the positions of the various
arguments and whether the interest rate is to be entered as
the actual rate (e.g., .05) or in percent (e.g., 5). An
exchange of the following form might be more palatable:
CI
I
ENTER CAPITAL AMOUNT IN DOLLARS
0:
1000
ENTER INTEREST IN PERCENT
0:
5
ENTER PERIOD IN YEARS
0:
4
RESULT IS 1215 050625

It is necessary that each of the keyboard entries


(1000, 5, and 4) occurring in such an exchange be accepted
not as an ordinary entry (which would only evoke the
response 1000, etc.), but as data to be used within the
function CI. Facilities for this are provided in two ways,
termed gYslYBt§Q ~n2Yt, and gngrgQteL input.
The definition of the function CI is shown at the end
of this section.

~Ys!Y~t~g ~n2Yt. The quad symbol 0 appearing anywhere other


than immediately to the left of a specification arrow
accepts keyboard input as follows: the two symbols 0: are
printed, the paper is spaced up one line, and the keyboard
unlocks. Any valid expression entered at this point is
evaluated and the result is substituted for the quad. For
example:
VZ+F
[ 1J Z+4xD*2
[2J V
F
0:
3
36
F
0:
3f2
9

3.24
An invalid entry in response to request for a quad
input induces an appropriate error report, after which input
is again awaited at the same point. A sys·tem command
entered will be executed, after which (except in the case of
one which replaces the active workspace) a valid expression
will again be awaited. An empty input (i.e., a carriage
return alone or spaces and a carriage return) is rejected
and the system again prints the symbols 0: and awaits input.
The symbols 0: are printed to alert the user to the
type of input expected; they can be changed by the library
function SFEI as described in Part 4.

~11S!;£S!9.t.§;£ !.n12yt, The quote-quad symbol [!] (L, e., a quad


overstruck with a quote) accepts character input: the
keyboard unlocks at the left margin and data entered are
accepted as characters. For example:
X+·[!]
C.AN'T (Quote-quad input, not indented)
X
CAN'T

~~9.S!2~ t~QID ~n2yt lQQR. If evaluated or character input


occurs within an endless loop in a function, it may be
impossible to escape by the usual device of strikinq the
attention button. Escape from 0 input can be achiev~d by
entering -+. Escape from [!] input can be achieved by typing
the three letters OUT, in that order, but with a backspace
between each pair so that they all overstrike. The effect
is exactly as if the symbol -+ were entered while suspended.

:N.1Q.~ID<!l
Q.\!tQ.\!t,. The quad symbol appearing immediately to the
left of a specification arrow indicates that the value of
the expression to the right of the arrow is to be printed.
Hence, D+X is equivalent to the statement X. The longer
form D+X is useful when employing multiple specification.
For example, D+Q+X*2 assigns to Q the value X*2 and then
prints the value of X*2.
The page width (measured in characters) may be set to
any value N in the range 30-130 by entering the command
)WIDTH N. It may also be set by the library function WIDTH
which may be used within a defined function. (See Part 4.)

3.25
M~t~~9g~~~9~§ 9Y~P~~. A sequence of expressions separated
by semi-colons will cause the values of the expressions to
be printed, with no intervening carriage returns or spaces
except those implicit in the display of the values.

The primary use of this form is for output in which


some of the expressions yield numbers and some yield
I
characters. For ex~mple, if X+2 14 , then:

'THE VALUE OF X IS ';X


THE VALUE OF X IS 2 14
A further example of mixed output is furnished by the
definition of the function CI which introduced the present
section:

VCI;A;I;Y
[1J 'ENTER CAPITAL AMOUNT IN DOLLARS'
[ 2J A+-O
[3J 'ENTER INTEREST IN PERCENT'
[ 4J I+-O
[5J 'ENTER PERIOD IN YEARS'
[6J Y+-O
[7J 'RESULT IS ';Ax(1+.01 xI)*YV
RECTANGULAR ARRAYS

Jnt~Qgy£tiQn. A single element of a rectangular array can


be selected by specifying its ingiQ~~; the number of indices
required is called the dimensionality or ~gnk of the array.
Thus a vector is of rank 1, a IDgtrix (in which the first
index selects a row and the second a column) is of rank 2,
and a scalar (since it permits no selection by indices) is
an array of rank O. Rectangular arrays of higher rank may
be used, and are called 3-dimensional, 4-dimensional, etc.

This section treats the reshaping and indexing of


arrays, and the form of array output. The following section
treats the four ways in which the basic scalar functions are
extended to arrays, and the next section thereafter treats
the definition of certain mixed functions on arrays.

3.26
y§gtQ~§, ~!m~n§1Qn, g~t§n~tiQD. If x is a vector, then pX
denotes its dimension. For example, if X+2 3 5 7 11, then
pX is 5, and if Y~'ABC' , then pY is 3. A single character
entered in quotes or in response to a ~ input is a scalar,
not a vector of dimension 1; this parallels the case of a
single number, which is also a. scalar.

Qstgnst!Qn chains two vectors (or scalars) together to


form a vector; it is denoted by a comma. For example:
X+·2 3 5 7 11
X,X
2 3 5 7 11 2 3 5 7 11

In general, the dimension of X,Y is equal to the total


number of e l.emerrts in X and .Y. A numeric vector cannot be
catenated with a character vector. (However, see
Heterogeneous Output.)

M~!:t~1gg§, ~!.:mgn§1Qn,
±:sygl. The monadic function p applied
to an array A yields "the §.i~§ of A, that is, a vector whose
components are the dimensions of A. For example, if A is
the matrix

1 2 3 4
5 6 7 8
9 1.0 11. 12

of t.h re e rows and four columns, then pA is the vector 3 4.

Since pA contains one component for each coordinate of


A, the expression ppA is the rank of A. Table 3.4
illustrates the values of pA and ppA for arrays of rank 0
(scalars) up to rank 3. In particular, the function p
applied to a scalar yields an empty vector.

Type of Array pA ppA pppA

Scalar 0 1
Vector N 1 1
Matrix M N 2 1
3-Dimensional L M N 3 1
- -
Table 3.4: DIMENSION AND
RANK VECTORS

3.27
The monadic functjon ~gY§l is denoted by a comma; when
applied to any array A it produces a vector whose elements
are the elements of A in row order. For example, if A is
the matrix

2
10 12
4 6
14
8
16
I
18 20 22 24

and if V+,A then V is a vector of dimension 12 whose


elements are the integers 2 4 6 8 10 12 24. If A
is a vector, then ,A is equivalent to A; if A is a scalar,
then ,A is a vector of dimension 1.

R§~hS2§. The dyadic function p ~~~hgg§a its right argument


to the dimension specified by its left argument. If M+DpV,
then M is an array of dimension D whose elements are the
elements of V. For example, 2 3p1 2 3 4 5 6 is the matrix

1 2 3
456

If N, the total number of elements required in the


array Dp V, is equal ttl the dimension of the vector V, then
the ravel of Dp V is equal to V • If N is less than p V, then
only the first N elements of V are used; if N is greater
than p V, then the elements of V are repeated cyclically.
For example, 2 3p 1 2 is the matrix

1 2 1
2 1 2

and 3 3p 1 0 0 0 is the identity matrix

1 0 0
0 1 0
0 0 1

3.28
More generally, if A is any array, then DpA is
equivalent to Dp , A. For example, if A is the matrix

123
456

then 3 Ei pA is the matrix


1 2 3 4 5
6 1 2 3 4
5 6 1 2 3

The expressions opX and 0 3pX and 3 OpX and 0 OpX are
all valid; anyone or more of the dimensions of an array may
be zero.

.9.J ..?l!lP-ty .iiJ:'-.!"..§.y_s · A vector of dimension zero contains


Pl?.§.§
no components and is called an ..e.ID.P_t.Y Y..e..cj:J~I. Three
expressions which yield empty vectors are 1 0 and ' , and p
applied to any scalar. An empty vector prints as a blank
line.
One important use of the empty vector has already been
illustrated: when one occurs as the argument of a branch,
the effect is to continue the normal sequence.
The following function for determining the
replesentation of any positive integer N in a base B number
system shows a typical use of the empty vector in
initializing a ve ct.o r Z which is to be bu.ilt up by
successive catenations:
'VZ+B BASE N
[ 1. ] Z"''-10
[ :? ] z+-(BIN),Z
[ 3] N~(-LN~B
[ L~ ] +2xN>O'V
10 BASE 1776
1 7 7 6
8 BASE 1776
3 3 6 0

Empty arrays of higher rank can be useful in analogous


ways in conjunction with the ~~.PEIl§j..9.D function described in
the section on Mixed Functions.

3.29
JD9~~iEg. If X is a vector and I is a scalar, then XCI]
denotes the Ith element of X. For example, if X+2 3 5 7 11
then X[ 2 J is 3.
If the index I is a vector, then X[IJ is the vector
obtained by selecting from X the elements indicated by
I
successive components of I. For example, X[1 3 5J is
2 5 11 and X [5 4 3 2 1 J is 11 7 5 3 2 and X [ 1 3 ] is 2 3 5.
If the elements of I do not belong to the set of indices of
X, then the expression XlIJ induces an iDg~~ ~rrQr report.
In general, pX[IJ is equal to pI. In particular, if I
is a scalar, then XCI] is a scalar, and if I is a matrix,
then X[IJ is a matrix. For example:
A+' ABCDEFG'
M+4 3p3 1 4 2 1 4 4 1 2 4 1 4
M
314
214
412
414
A[M]

CAD
BAD
DAB
DAD

If M is a matrix, then M is indexed by a two-part list


of the form I;J where I selects the row (or rows) and J
selects the column (or columns). For example, if M is the
matrix
1 2 3 4
5 6 7 8
9 10 11 12

then M[2;3J is the element 7 and M[1 3 ,. 2 3 4J is the matrix


2 3 4
10 11 12

3.30
In general, pM[I;JJ is equal to (pI),pJ. Hence i f ]
and J are both vectors, then M[I;JJ is a matrix; if both]
and J are scalars, M[I;JJ is a scalar; if I is a vector and
J is a scalar (or vice versa), M[I;JJ is a vector. The
indices are not limited to vectors, but may be of higher
rank. For example, if I is a 3 by 4 matrix, and J is a
vector of dimension 6, then M[I;JJ is of dimension 3 4 6,
and M[J;IJ is of dimension 6 3 4. In particular, if T and P
and Q are matrices, and if R+T[P;QJ, then R is an array of
rank 4 and R[I;J;K;LJ is equal to T[P[I;JJ;Q[K;LJJ.

The form M[];J iLdicates that all columns are selected,


a.nd the form M[;JJ indicates that all rows are selected.
For example, M[2;J is 5 6 7 8 and M[;2 1J is
2 1
6 5
10 9

The following example illustrates the use of a matrix


indexing a matrix to obtain a three-dimensional array:

M+4 3p3 1 4 2 1 4 4 1 2 4 1 4
M

3 1 Lj.
r) tj.
L. 1
Lj. 1 2
L~ 1 1+
M[M; ]

L~ 1 :2
3 1 1+
Lj. 1 I..j.

2 1 1+
:3 1 )+
q. 1 ,+

Lj. 1 4
:3 1 4
2 1 4

L+ 1 4
:3 1 4
L+ 1 4

3.31
Permutations are an interesting use of indexing. A
vector P whose elements are some permutation of its own
indices is called a Q..~J;Jll.\l.t.qt..:lQJl. Q.:f.. QX..<iex.. p P, For example,
3 1 4 2 is a permutation of order 4. If X is any vector of
the same dimension as P, then XCPJ produces a permutation of
X. Moreover, if pP is equal to (pM)[ 1J, then M[P; J permutes
the column vectors of M (i. e., interchanges the rows of M)
and is called a Q.,.o_:LlJm..Il. Q..~:(.m.\l.t.q,t.i.QJl.. Similarly, if p P equals
( pM) [ 2 J, then M [ ; P J is a :('Q.~ R..~m\l.t.qt..i.QJl. of M.

:LIl.ci~~:lI!fl.
Q.Il. ·t;h..~ :L~t:.t... An array appearing to the left of a
specification arrow may be indexed, in which case only the
selected positions are affected by the specification. For
example:

X+2 3 5 7 11
X[1 3J+6 8
K
6 3 8 7 11
The normal restrictions on indexing apply; in
particular, a variable which has not already been assigned a
value cannot be indexed, and an out-of-range index value
cannot be used.

JDg~~ Q~igiD. In l=Q~jgiD indexing, X[1J is the leading


element of the vector X and X[pXJ is the last element. In
.Q=.Qf'igj..!] indexing, X[oJ is the leading element and X[-1+pXJ
is the last. a-origin indexing is instituted by the command
)ORIGIN o. The command )ORIGIN 1 restores I-origin
indexing. The index origin in effect applies to all
coordinates of all rectangular arrays.

The function ORIGIN in Library 1 WSFNS may also be used


to control the index origin. It may be executed within a
function. (See Part 4.)

In certain expressions such as +/[J]M and K~[JJM (to be


treated more fully in the two following sections), the value
of J determines the coordinate of the array M along which
the function is to be applied. Since the numbering of
coordinates follows the index origin, a change of index
origin also affects the behavior of such expressions.

The index origin also affects four other functions, the


monadic and the dyadic forms of ? and 1. The expression 1N
yields a vector of the first N integers beginning with the
index origin. Hence X[lNJ selects the first N components of
X in either origin. Moreover, 11 is a one-element vector
having the value 0 in a-origin and 1 in I-origin; 10 is an
empty vector in either origin.

3.32
The index origin remains associated with a workspace;
in particular, the index origin of an active workspace is
not affected by a copy command. A clean workspace provided
on sign-on or by the command )CLEAR is in I-origin. All
definitions and examples in this text are expressed in
l--origin.

bl~~g.y QY~12Y.t.
Character arrays print with no spaces between
components in each row; other arrays print with at least one
space. If a vector or a row of a matrix requires more than
one line, succeeding lines are indented.

A matrix prints with all columns aligned and with a


blank line before the first row. A matrix of dimension N,1
prints as a single column.

FUNCTIONS ON ARRAYS

There are four ways in which the scalar functions of


Table 3 2 extend to arrays: element-by-element, reduction,
8

inner product, and outer product. Reduction and outer


product are defined on any arrays, but the other two
extensions are defined only on arrays whose sizes satisfy a
ce r t ad n relationship called QQnfQrmabilit~. For the
element-by-element extension, conformability requires that
the shapes of the arrays agree, unless one is a scalar. The
rE~quirements for inner product are shown in Table 3. 6.

Sgg!~~ fYn~tiQn§. All of the scalar functions of Table 3.2


are extended to arrays element by element. Thus if M and N
are matrices of the same size, f is a scalar function, and
P+MfN, then P[I;JJ equals M[I;JJfN[I;JJ, and if Q+fN, then
Q [ I ; J] is equal to f N[ I ; JJ
0

If M and N are not of the same size, then MfN is


undefined (and induces a !gngtb or J::ank ~J::;rQr report) unless
one or other of M and N is a scalar or one-element array, in
Which case the single element is applied to each element of
the other argument. In particular, a scalar versus an empty
array produces an empty array.

An expression or function definition which employs only


scalar functions and scalar constants extends to arrays like
a scalar function.

B§gy~t~Qn. The §Um-~§gygtiQn. of a vector X is denoted by


+/X and defined as the sum of all components of X. More
gE~nerally, for any scalar dyadic function f, the expression
fiX is equiva.lent to X[1]fX[2Jfo oofX[pX], where evaluation
is from right.most to leftmost as usual. A user-defined
function cannot be used in reduction.

3 .. 33
If X is a vector of dimension zero, then fiX yields the
identity element of the function f (listed in Table 3.5) if
it exists; if X is a scalar or a vector of dimension 1, then
fiX yields the value of the single element of X.
The result of reducing any vector or scalar is a
scalar.

Dyadic Identity Left-


Function Element Right

Times x 1 R L
Plus + 0 R L
Divide ... 1 R
Minus - 0 R
Power * 1 R
Logarithm 6t None
Maximum r - 70237 0 • L R
oE75

Minimum L 7.237 0 0 L R
0E75

Residue I 0 L
Circle 0 None
Out of
, 1 L
Or v 0 L R
And A 1 L R
Nor ¥ None
Nand 1'< . None
Equal = 1 Apply L R
Not equal ;t 0 for L R
Greater > o~ logical R
Not less ~ 1 arguments R
Less < 0 only L
Not greater $ 1 L
Table 3.5: IDENTITY ELEMENTS OF
PRIMITIVE SCALAR
DYADIC FUNCTIONS

For a matrix M, reduction can proceed along the first


coordinate (denoted by f/[1]M) or along the second
coordinate (f/[2]M)o The result in either case is a vector;
in general, reduction applied to any non-scalar array A
produces a result of rank one less than the rank of A (hence
the term ~§gygt~Qn). The numbering of coordinates follows
the index origin, and an attempt to reduce along a
non-existent coordinate will result in an index error.

3.34
Since +/[1]M scans over the row index of M it sums each
gQ~Ymn vector of M, and +/[2]M sums the ~Q~ vectors of M.
F'or example, if M is the matrix

123
456

then +/[1]M is 5 7 9 and +/[2]M is 6 15.

In reducing along the last coordinate of an array, the


coordinate indicator may be elided thus +/M denotes
summing over each of the rows of M and +/V denotes summing
over the last (and only) coordinate of the vector V.
Reduction over the first coordinate
of M by a function
f may be obtained by using the expression ffM. The symbol f
is formed by overstriking the solidus with the minus sign.

1:!:!!!~.!' E!'Q.Q.~9.t-.
The familiar matrix product is denoted by
C+A+.xB. If A and B are matrices, then C is a matrix such
that C[I;J] is equal to +/A[I;]xB[;JJo A similar definition
applies to Af.gB where f and g are any of the standard
scalar dyadic functions.

If A is a vector and B is a matrix, then C is a vector


such that C[J] is equal to +/AxB [ ;J]. If B is a vector and
A is a matrix, then C is a vector such that C[I] is equal to
+ / A [I; ] xB If both A and B are vectors,
0 then A +. <B is the
scalar +/AxB.

Tr.le las t dimension 0 f the pre-mult ipli er A mus t equal


the first dimension of the post-multiplier B, except that if
either argument is a scalar, it is extended in the usual
way. For non-scalar arguments, the dimension of the result
is equal to (-1i-pA), 1i-pB. (See the function .Q.,rQP in the
section on Mixed Functions.) In other words, the dimension
of the result is equal to (pA), pB except for the two inner
dimensions (-ltpA and 1tpB), which must agree and which are
eliminated by the reduction over them.

Definitions for various cases are shown in Table 3.6.

Q~~~~ 2~Q9~£~. The outer product of two arrays X and Y with


respect~to a standard scalar dyadic function g is denoted by
xOagYand yields an array of dimension (pX),pY, formed by
applying g to every pair of components of X and Y.

3.35
Conformability Definition
pA oB oAf.gB requirements Z+-Af.gB
Z+-f/AqB
V Z+-f /A gB
U Z+-f/AgB
U V u=v Z+-f/AqB
V W W Z[I ]+-f / AgB [ ; I]
T u T Z[ I] +-f/ A[ I; ] 9 B
U V W W U=V Z[I]+-f/AgB[ ;I]
T u V T U=V Z[I]+-f/A[I; ]gB
T U V W T W U=V Z[I;J]+-f/A[I;JgB[;J]
Table 3.6: INNER PRODUCTS FOR PRIMITIVE SCALAR
DYADIC FUNCTIONS f AND 9

If X and Yare vectors and Z+-Xo 9 Y, then


0 Z[I;JJ is
equal to X[I]gY[J]o For example:

X+-l3
Y+-l4
XOoXY

1 2 3 4
2 4 6 8
3 6 9 12
XO o2Y

1 0 0 0
1 1 0 0
1 1 1 0

If X is a vector and Y is a matrix, and Z+-XoogY, then


Z[I;J;KJ is equal to X[IJgY[J;KJo Definitions for various
cases are shown in Table 3.7.

Definition
pA pB p A° 0 gB Z+-A ° . gB
Z+-AgB
V V Z[IJ+-AgB[IJ
u U Z [I J+-A [I JgB
U V U V Z[I;JJ+-A[IJgB[J]
V W V w Z[I;JJ+-AgB[I;JJ
T u T U Z[I;JJ+-A[I;JJgB
U V W U V w Z[I;J;KJ+-A[IJgB[J;KJ
T u V T U V Z[I;J;KJ+-A[I;JJgBCKJ
T u V W T U V w Z[I;J;K;LJ+-A[I;JJgB[K;LJ
Table 3.7: OUTER PRODUCTS FOR PRIMITIVE
SCALAR DYADIC FUNCTION 9

3.36
MIXED FUNCTIONS

!~~~Q9g~~!Qg. The scalar functions listed in Table 3.2 each


t.ake a scalar argument-- (or arguments) and yield a scalar
result; each is also extended element by elemen·t to arrays.
The m!~~9 functions of Table 3.8, on the other hand, may be
de f i ned on vector arguments to yield a scalar resul t or a
vector result, or may be defined on scalar arguments to
yield a vector result. In extending these definitions to
arrays of higher rank, it may therefore be necessary to
specify which coordinate of an array the mixed function is
applied to. ~rhe expression [J] following a function symbol
indicates that the function is applied to the Jth
coordinate. If the expression is elided, the function
applies to t.he last coordinate of the argument array. These
conventions aqre.e with those used earlier in reduction.

The numbering of coordinates follows the index origin.

1';r,g!.l'§.P9E~. The expression 2 1~M yields the .tf.'.9!J§P9'§§ of the


matrix M; that is, if R+2 1~M, then each element R[I;J] is
equal t.o M[J;I]. For example:
M 2 1~M
1 2 3 4 159
5 6 7 8 2 6 10
9 10 11 12 3 7 11
4 8 12

If P is any permutation of order ppA, then P~A is an


array similar to A except that the coordinates are permuted:
the Ith coordinate becomes' the P[I]th coordinate of the
result. Hence, if R+P~A, then (pR)[PJ is equal to pA. For
example:
A+-2 3 5 7p 1210
pA.
235 7
P+·2 3 4 1
pP~A
7 2 3 5

3.37
Name Sign l Definition or example 2

Size pA pP ++ 4 pE ++ 3 4 p5 ++ 1 0

Reshape VpA Reshape A to dimension V 3 4p 1 12 ++ E


12pE ++ 1 12 OpE ++ 1 0
Ravel ,A ,A ++ ( x I p A ) pA ,E ++112 p , 5 ++ 1

Catenate V .. V P . 1 2 ++ 2 3 5 7 1 2 'T' .. 'HIS' ++ ' THIS'


V[A J P[2J ++3 P[4 3 2 lJ ++7 5 3 2
Index 3 4 M [A ; A J E[l 3;3 2 lJ ++ 3 2 1
11 10 9
A [A ; ... E[l;J ++ 1 2 3 4 ABCD
.... ;A J E[;lJ ++ 1 5 9 'ABCDEFGHIJKL'[EJ ++ EFGH
IJKL
Index 1S First S integers 14 ++ 1 2 3 4
generator3 10 ++ an empty vector

Index of 3 V1 A Least index of A P13 ++2 5 1 2 5


in V, or l+pV P1E ++ 3 5 4 5
4 414 ++ 1 5 555
Take VtA Take or drop IV[IJ first 2 3tX ++ ABC
(V[IJ~O) or last (V[IJ<O) EFG
Drop V{-A } elements of coordinate I - 2tP ++ 5 7
Grade up3 5 I~A The permutat10n which ~3 5 3 2 ++ 4 1 3 2
)0would order A (ascend-
Grade down3 5 VA ing or descending) V3 5 3 2 ++ 2 1 3 4
1 3
Compress 5 VIA 1 0 1 OIP ++ 2 5 1 0 1 OlE ++ 5 7
9 11
1 0 1/[lJE ++ 1 2 3 4 ++ 1 0 liE
9 10 11 12
A BCD
Exp and f V\A 1 0 1\12 ++ 1 0 2 1 0 1 1 l\X ++ E FGH
I JKL
DCBA IJKL
Reverse 5 <PA <pX ++ HGFE ¢[lJX ++ eX ++ EFGH
LKJI <pP ++ 7 5 3 2 ABCD
BCDA
Rotate 5 A<pA 3<pP ++ 7 2 3 5 ++ -l<pP 1 0 -l<pX ++ EFGH
LIJK
AEI
V~A Coordinate I of A 2 l~X ++ BFJ
becomes coordinate CGK
Transpose V[IJ of result 1 l~E ++ 1 6 11 DHL

~A Transpose last two coordinates ~E


++ 2 l~E
o
1 1 0
Membership AEA pWEY ++ pW EEP ++ 10 1 0
PE14 ++ 1 1 0 0 0 0 0 0
Decode V.L V 10.Ll 7 7 6 ++ 1776 24 60 60.Ll 2 3 ++ 3723

Encode VTS 24 60 60T3723 ++ 1 2 3 60 60T3723 ++ 2 3


Dea1 3 S?S WrY ++ Random deal of W elements from 1Y

Table 3.8: PRIMITIVE MIXED FUNCTIONS (see adjacent notes)

3.38
1. Restrictions on argument ranks are indicated by: S for
scalar, V for vector, M for matrix, A for Any. Except as
t.h e first argument of S 1 A or S LA], a scalar may be used
instead of a vector. A one-element array may replace any
scalar.

2. Arrays used 1 2 3 4 ABeD


in examples: P +-+ 2 3 5 7 E +-+ 5 6 7 8 X +-+ EFGH
9 10 11 12 IJKL
3. Function depends on index origin.

4. Elision of any index selects all along that coordinate.


5. The function is applied along the last coordinate~ the
symbols f, \, and e are equivalent to I, \, and ¢,
respectively, except that the function is applied along the
first coordinate. If [S] appears after any of the symbols,
the relevant coordinate is determined by the scalar S.

Notes to Table 3.8

More generally, Q~A is a valid expression if Q is any


vector of dimension ppA whose elements are chosen from (and
exhaust) the elements of lflQ. For example, if ppA is equal
to 3, then 1 1 2 and 2 1 1 and 1 1 1 are suitable values for
Q but 1 3 1 is not. Just as for the case P~A where P is a
pennutation vector, the Ith coordinate becomes the Q[IJth
coordinate of Q~A. However, in this case two or more of the
coordinates of A may map into a single coordinate of the
result, thus producing a diagonal section of A as
illustrated below:

A+3 3P19
A

1 2 3
1-
4 o 6
7 13 9
1 1~A
1 5 9

3.39
Table 3.9 shows the detailed definitions of
transposition for a variety of cases.

MQn~~1g ~~~n§2Q§§. The expression ~A yields the array A


with the last two coordinates interchanged. For a vector V,
matrix M, and three dimensional array T, the following
relations hold:

~V is equivalent to l~V (and hence to V)


~M is equivalent to 2 l~M (ordinary matrix transpose)
~T is equivalent to 1 3 2~T

BQt~t§. If K is a scalar or one-element vector and X is a


vector, then K~X is a cyclic rotation of X defined as
follows: K~X is equal to X[1+(pX)!-1+K+1PXJo For example,
if X+2 3 5 7 11, then 2~X is equal to 5 7 11 2 3, and -2~X
is equal to 7 11 2 3 5. In a-origin indexing, the
definition for K~X becomes X[(pX)IK+1PXJ.

If the rank of X exceeds 1, then the coordinate J along


which rotation is to be performed may be specified in the
form Z+K~[JJX. Moreover, the dimension of K must equal the
remaining dimensions of X, and each vector along the Jth
coordinate of X is rotated as specified by the corresponding
element of K. A scalar K is extended in the usual manner.

Case pR Definition

R+l~V pV R+V
R+l 2~M pM R+M
R+2 l~M ( pM) [ 2 lJ R[I;JJ+M[J;IJ
R+l l~M L /pM R[IJ+M[I;IJ
R+l 2 3~T pT R+T
R+l 3 2~T (pT)[l 3 2J R[I;J;KJ+T[I;K;JJ
R+2 3 l~T (plJ ) [ 3 1 2 J R[I;J;KJ+T[J;K;IJ
R+3 1 2~T (pT)[2 3 lJ R[I;J;KJ+T[K;I;JJ
R+l 1 2~T (L/(pT)[l 2J),(pT)[3J R[I;JJ+T[I;I;JJ
R+l 2 l~T (L/(pT)[l 3]),(p27 ) [ 2 J R[I;JJ+T[I;J;IJ
R+2 1 l~T (L/(pT)[2 3]),(pT)[lJ R[I;JJ+T[J;I;IJ
R+l 1 l~T L /p T R[IJ+T[I;I;IJ
Table 3.9: TRANSPOSITION

3.40
For example, if pX is 3 4 and J is 2, then K must be of
dimension 3 and Z[I;] is equal to K[I]~X[I;]o If J is 1,
then pK must be 4, and Z[;I] is equal to K[I]¢X[;I]. If X is
a three-dimensional array, then K must be a matrix or a
scalar. For example:

M 0 1 2 3¢[1]M 1 2 3<P[2]M

1 2 3 4 1 6 11 4 2 3 4 1
5 6 7 8 5 10 3 8 7 8 5 6
9 10 11 12 9 2 7 12 12 9 10 11

The expression KeX denotes rotation along the first


coordinate of X. The symbol e is formed by overstriking a 0
w i, th a minus sign.

B§Y§~§~. If X is a vector and R+¢X, then R is equal to X


except, that t:he elements appear in reverse order. Formally,
R is equal to X[1+(pX)-lpX]. In o-origin indexing, the
appropriate expression is X[-1+(pX)-lpX].

If A is any array, J is a scalar or one-element vector,


and R+¢[JJA, then R is an array like A except that the order
of the elements is reversed along the Jth coordinate. For
examp Le :

A ¢[1]A ¢[2]A
123 456 321
456 123 654

The expression ¢A denotes reversal along the last


coordinate of A, and eA denotes reversal along the first
coordinate. For example, if A is of rank 3, then ¢A is
equ i valent to ¢[ 3]A, and eA is equivalent to <p[ 1 JA.

~~9!!1P.!'~§'§.
The expression U / X denotes .9QIDP.!"§.§§i-.9Il of X by U.
If U is a logical vector (comprising elements having only
t.he value s 0 or 1) and x i s a vector of the same dimens ion,
then U/X produces a vector result of +/U elements chosen
from those elements of X corresponding to non-zero elements
of U. For example, if X+2 3 5 7 11 and U+1 0 1 1 0 then
U / Xis 2 5 7 and ('" U) / xis 3 11 0

To be conformable, the dimensions of the arguments must


agree, except that a scalar (or one-element vector) left
argument is extended to apply to all elements of the right
argument. Hence 1/X is equal to X and o/X is an empty
vector. A scalar right a.rqument; is not extended. The
result in every case is a vector.

3.41
If
M is a matrix, then U/[1]M denotes compression
the first coordinate,
~.!Q.!}g that is, the compression
operates on each column vector and therefore deletes certain
rows. It is called £Q1YIDD compression. Similarly, U/[2]M
(or simply U/M) denotes ~g~ compression. The result in
every case is a matrix. As in reduction, U/M denotes
compression along the last coordinate, and UfM denotes
compression along the first.
~~EE.!}g. Expansion is the converse of compression and is
denoted by U\Xo If Y+U\X, then U/Y is equal to X and (if X
is an array of numbers) (~U)/Y is an array of zeros. In
other words, U\X expands X to the format indicated by the
Q.!}§§ in U and fills in zeros elsewhere. To be conformable,
+/U must equal pX.

If x is an array of characters, then spaces are


supplied rather than zeros, i.e., if Y+U\X then (~U)/Y is an
array of the space character' '. Again, U\[J]M denotes
expansion along the Jth coordinate, U\M denotes expansion
along the last, and U~M denotes expansion along the first.
See Table 3.8 for examples of expansion.
A scalar left argument is not extended.
g~£Qg~. The expression RiX denotes the value of the vector
X evaluated in a number system with radices
R[1],R[2],0 00 ,R[pR]o For example, if R+24 60 60 and
X+1 2 3 is a vector of elapsed time in hours, minutes, and
seconds, then RiX has the value 3723, and is the
corresponding elapsed time in seconds. Similarly,
10 10 10 10 i 1 7 7 6 is equal to 1776, and 2 2 2 i 1 0 1 is
equal to 5. Formally, RiX is equal to +/WxX, where W is the
weighting vector determined as follows: W[pW] is equal to
1, and W[I-1] is equal to R[I]xW[I]. For example, if R is
24 60 60, then W is 3600 60 1.

The result is a scalar.


The arguments R and X must be of the same dimension,
except that either may be a scalar (or one-element vector).
For example, 10 i 1 7 7 6 is equal to 17760 The arguments
are not restricted to integer values. If X is a scalar,
then XiC is the value of a polynomial in X with coefficients
C, arranged in order of descending powers of X.
The decode function is commonly applied in work with
fixed-base number systems and is often called the bgQ~
y~!y§ function.

3.42
~QgQ~~. The ~n£Q~~ function RTN denotes the representation
of the scala.r N in the base-R number system. Thus, if
Z+RTN, then (x/R),IN-RJ..Z is equal to zero. F'or example,
2 2 2 2 T 5 is 0 1 0 1 and 2 2 2 T 5 is 1 0 1 and 2 2 T 5 is
o 1. The dimension of RTN is the dimension of R. The
encode function is also called ~§Q~§§§nt~tiQn.

!n~~~ Q~. If V is a vector and S is a scalar, then J+V1S


yields the position of the earliest occurrence of S in V.
If S does not equal any element of V, then J has the value
(11)+pV. Clearly, this value depends, as does any result of
this function, on the index origin, and is one greater than
t:he largest permissible index of V.
If S is a vector, then J is a vector such that J[I] is
t.he index in V of S[ I] For example:
0

1ABCDEFGH'1'GAFFE'
7 1 665

If X is a numerical vector, then the expression X1f/X


yields the index of the (first) maximum element in X. For
examp l e , if X is the vector 8 3 5 13 2 7 9, then fiX is 13
and X 1 f / Xis 4 •
The result in every case has the same dimensions as the
righthand argument of 1. For example, if Z+V1S, and S is a
matrix, then Z[I;J] is equal to V1S[I;JJ.

~~~znQ~!:.§!h!.12.
The function X E Y yields a logical array of the
same dimension as X. Any particular element of XEY has the
value 1 if the corresponding element of X belongs to Y, that
is, if it occurs as some element of Y. For example,
(17)E3 5 is equal to 0 0 1 0 1 0 0 and 'ABCDEFGH'E'COFFEE'
equals 0 0 1 0 1 1 0 o.
If the vector U represents the universal set in some
finite universe of discourse, then UEA is the characteristic
of the set A, and the membership function is therefore also
called the g)-1s.~g(;~:!;~~i.§.ti.Q function.
The size of the result of the function E is determined
by the size of the left argument, whereas the si.ze of the
result of the dyadic function 1 is determined by the size of
the right argument. However, the left arguments of both
frequently play the role of specifying the universe of
d i acour s e ,

3.43
~g~~ gng Q~Q~. If V is a vector and S is a scalar between 0
and pV, then StV takes the first S components of V. For
example, if V+17, -then 3tV is 1 2 3 and OtV is 10, and 8tV
yields a domain error.
If S is chosen from the set -lPV, then StV takes the
last Is elements of V. For example, 3tV is 5 6 7.
If A is an array, then WtA is valid only if W has one
element for each dimension of A, and WeI] determines what is
to be taken along the Ith coordinate of A. For example, if
A + 3 4Pl12, then 2 -3tA is the matrix
234
678

The function g~Q~ (~) is defined analogously, except


that the indicated number of elements are dropped rather
than taken. For example, -1 l~A is the same matrix as the
one displayed in the preceding paragraph.

The rank of the result of the take and drop functions


is the same as the rank of the right argument. The take and
drop functions are similar to the transpose in that the left
argument concerns the dimension vector of the right
argument.

G~gg§ YQ gil9 9Q~D. The function ~V produces the permutation


which would order V, that is V[~V] is in ascending order.
For example, if V is the vector 7 1 16 5 3 9, then ~V is the
vector 2 5 4 1 6 3, since 2 is the index of the first in
rank, 5 is the index of the second in rank, and so on. The
symbol ~ is formed by overstriking I and ~.
If P is a permutation vector, then ~P is the
permutation inverse to P. If a vector D contains duplicate
elements, then the ranking among any set of equal elements
is determined by their positions in D. For example,
~5 3 7 3 9 2 is the vector 6 2 4 1 3 5.
The right argument of ~ may be any array A of rank
greater than zero, and the coordinate J along which the
grading is to be applied may be indicated by the usual
notation ~[J]A. The form ~A applies as usual to the last
coordinate. The result of ~A is of the same dimension as A.

The g~ggg gQ~n function t is the same as the function ~


except that the grading is determined in descending order.
Because of the treatment of duplicate items, the expression
A/(~V)=~tv has the value 1 if and only if the elements of
the vector V are all distinct.

3.44
~~§9:1.. The function M? N produces a vector of dimension M
obtained by making M random selections, without replacement,
from the population IN. In particular, N?N yields a random
permuta.tion of order N. Both arguments are limited to
scalars or one-element arrays.

~;Q:t.nm§nt§..
The lamp symbol A, formed by overst.riking nand
0, signifies that what follows it is a comment, for
illumination only and not to be executed; it may occur only
as the first character in a statement, but may be used in
defined functions.

MULTIPLE SPECIFICATION
Specification (+) may (like any other function) occur
repeatedly in a single statement. For example, the
execution of the statement Z+XxA+3 will assign to A the
value 3, then multiply this assigned value of A by X and
a.ssign the resulting value to Z.
Multiple specification is useful for initializing
variables. For example:
X+Y+1+Z+0

sets X and Y to land Z to O.


A branch may occur in a statement together with one or
more specifications, provided that the branch is the last
operation to be executed (i.e., the leftmost). For example,
t.he st:atement -+Sx IN>I+I+1 first augments I, and then
branches to statement S if N exceeds the new value of I.
In the expression Z+(A+B)x(C+D) it is
immaterial
whet.her; the left or the right argument of the is evaluated
x
first, and hence no order is specified. The principle of no
specified order in such cases is also applied when the
expressions include specification. Since the order here is
sometimes material, there is no guarantee which of two or
more possible results will be produced.
Suppose, for example, that A is assigned the value 5
and the expression Z+(A+3)xA is then executed. If the left
argument of x is executed first, then A is assigned the
value 3, the right argument then has the new value 3 and Z
is finally assigned the value 9. If, on the other hand, the
right argument is evaluated first it has the value 5
initially assigned to A, the value 3 is then assigned to A
and multiplied by the 5 to yield a value of 15 to be
assigned to Z.

3.45
SYSTEM DEPENDENT FUNCTIONS

There are three main types of information about the


state of the system which are of value to the user:

1. general information common to all users, such as


date, time of day, and the current number of terminals
connected to the system.

2. information specific to the particular work


session, such as the time of sign-on, the central
computer time used, and the total keying time.

3. information specific to the active workspace, such


as the amount of storage available, and the condition
of the state indicator.

This information is provided by a single family of


functions denoted by I (formed by overstriking T, and ~),
and called the ~=B~~ID functions. The individual member
function is selected by the argument as shown in Table 3.10.
Times are all in units of one-sixtieth of a second, the date
is given as a six-digit integer in which the successive
digit pairs specify the month, day, and year, and the
available storage is given in b~±~~.

The byte is a unit of storage equal to 8 binary digits.


A variable requires for storage a small number of bytes of
overhead, plus a certain ,number of bytes per element
depending upon the form of its representation: 1 if the
elements are characters, 0.125 if the elements are logical,
4'if the elements are integers less than 2*31 in magnitude,
and 8 for other numbers.

In designing an algorithm for a particular purpose, it


frequently happens that one may trade time for space; that
is, an algorithm which requires little computer time may
require more storage space for intermediate results, and an
algorithm which requires little storage may be less
efficient in terms of time. Hence, the information provided
by the functions I21 (computer time used) and I22 (available
storage space) may be helpful in designing algorithms. For
example, the function TIME of Appendix B can be used to
determine the computer time used in the execution of a
function.

Moreover, since the functions I21 and I22 can, like all
of the I-beam functions, be used within a defined function,
they can be used to make the execution dependent upon the
space available or the computer time used.

3.46
X Definition of IX
19 Accumulated keyingtime (time during which the keyboard
has been unlocked awaiting entries) during this session.
20 The time of day.
2:1. The central computer time used in this session.
22 The a.mount of available space (in bytes).
221 The number of terminals currently connected.
24 The time at the beginning of this session.
2~) The date.
26 The first element of the vector I27.
27 The vector of statement numbers in the state indicator.
NOTES
1. All times in 1f60 seconds
2. Date is represented by a 6-digit integer; successive
digit pairs represent month, day, and year.
3. I27 yields a vector; all other results are scalars.

Table 3.10: SYSTEM DEPENDENT FUNCTIONS

$~]riDg ~iID~ is defined as the total accumulated time


since sign-on during which the keyboard has been unlocked
awaiting entry. The associated function (r19) may be used
in conjunction with 0 or ~ input to determine the amount of
time taken by a student in responding to a question. The
following example shows the definition and use of a
multiplication drill which tells the student how long he has
taken (in whole minutes and seconds) to answer each
question:

\1MULTDRILL N;X;Y;TIME
[1 J D+Y+?N
[2J TIME+r19
[3 J X+D
[4J TIME+(I19)-TIME
[5J -+8XlX~X/Y
[ 6J ' TIME: '; 2 t 60 60 60 T TIME
[7J -+1
[8J 'WRONG, TRY AGAIN'
[9J -+3\1
MULTDRILL 12 12
6 3
0:
18
TIME: 0 3
4 5
30
WRONG, TRY AGAIN
0:

3.47
Such a drill could be expanded to accumulate statistics of
the student's response times or to use some function of the
response times to control the difficulty of the questions
posed.

Since times are expressed in units of 1t60 seconds, the


time in hours, minutes, and seconds can be determined by an
expression of the form 3+24 60 60 60TI20. Similarly, a
3-element vector representing the date can be obtained from
the expression (3p100)TI25.
The expression I27 provides the vector of statement
numbers in the state indicator, with the first position
occupied by the number of the statement on which the
innermost function is suspended. If no functions are
suspended, the vector I27 is empty.
The expression I26 yields a scalar which is the first
element of I27. It is therefore equal to the number of the
statement being, or about to be, executed and is
particularly useful in branches. For example, +N+I26 causes
a forward jump of N statements. Moreover, entering +I26 is
a safe way to resume execution without having to read and
enter the statement number printed at the point of the last
suspension. It is even more convenient to resume by
entering +C, after first defining the function C as follows:
VZ+-C
[1J Z+-(I27)[2Jv

3.48
PA.RT 4

LIBRARY FDNCTIONS

A user may load or copy functions from any workspace


for which he knows the library number and workspace name
(and password, if any). Moreover a listing of the
workspaces in Library N can be obtained by the command
)LIB N for any 2Y~!!9 library, i.e., for any library whose
number is below 1000.

A public library may be used for the casual sharing of


functions among a group of co-workers. When intended for
more general use, a library function should be thoroughly
tested and well-documented, and should incorporate messages
for the guidance of the user. It is therefore good practice
to restrict certain of the public libraries to such
functions as are of general interest and have passed
appropriate acceptance tests.

In the APL\360 system as distributed, Library 1 is


restricted in this manner. This section treats each of the
workspaces in this library by loading each and displaying
the descriptions contained in the workspaces themselves.
Further information on the functions in each workspace can
(except in the case of the locked functions in WSFNS) be
obtained by displaying the function definitions.

)LOAD 1 ADVANCEDEX
ADVANCEDEX SAVED 07/1L~/(-,8
)FNS
AH ASSOC BIN COMB DTH ENTER F FC
G'C GCD GCV HILB HTD IN INV INVP
INl LFC LOOKUP PALL PER PERM PO POL
POLY POLiB RESET TIME TRU'TH ZERO
DESCRIBE

EACH OF THE VARIABLES OF THIS WORKSPACE WHICH BEGINS WITH THE


LETTER D IS THE DESCRIPTION OF THE FUNC'l'ION WHOSE NAME IS
OBTAINE'D BY REMOVING THE Do FOR FURTHER DErpAILS SgE APPENDIX
B OF THE APL\360 MANUALa

4.1
)LOAD 1 PLOTFORMAT
PLOTFORUqT SAVED 07/20/68 31 007 027

)FNS
AND DESCRIBE DFT EFT PLOT VS
DESCRIBE

THE FUNCTIONS INCLUDED IN THIS WORKSPACE ARE LISTED BELOW:


SYNTAX DESCRIPTION
Z+A ANI' B ESSENTIALLY A COLUMN-CATENA1 WITH SOME EXTRA
IOR,

EFFECTS WHEN THE ARGUMENTS ARE NOT MATRICESo


THIS FUNCTION IS DESIGNED TO BE USED EITHER
INDEPENDENTLY, OR IN CONJUNCTION WITH VS. IT
PROVIDES A CONVENIENT WAY OF FORMING INPUT
TO DFT AND EFT 0

Z+A DFT B FORMS FIXED-POINT OUTPUT o MORE DETAILED DIREC-


TIONS CAN BE FOUND IN THE VARIABLE HOWFORMATo
Z+A EFT B FORMS EXPONENTIAL OUTPUT o MORE DETAILED DIREC-
TIONS CAN BE FOUND IN THE VARIABLE HOWFORMAT 0

A PLOT B GRAPHS ONE OR MORE FUNCTIONS SIMULTANEOUSLYo


DIRECTIONS FOR USING PLOT CAN BE FOUND IN THE
VARIABLE HOWPLOTo
Z+A VS B ESSENTIALLY A COLUMN-CATENATOR, SIMILAR TO AND,
EXCEPT THAT THE RIGHT-HAND ARGUMENT MUST BE OF
RANK ~ 1 0IT IS DESIGNED PRIMARILY TO PROVIDE
CONVENIENT FORMATION OF INPUT TO PLOT FUNC-
TION. WHETHER USED BY ITSELF OR WITH AND, VS
WILL CAUSE ITS RIGHT ARGUMENT TO APPEAR AS THE
LEFTMOST COLUMN OF THE RESULTANT ARRAY. (THE
RESULTANT WILL BE AN ARRAY OF RANK THREE,
CONSISTING OF A SINGLE PLANE)o
BOTH AND AND VS WORK WITH EITHER 1 OR 0 -ORIGIN INDEXINGo

4.2
HOWFORMAT

THE FUNCTIONS DFT AND EFT WILL ARRAY NUMBERS IN DECIMAL AND
EXPONENTIAL FORM, RESPECTIVELY, FOR TABULAR OUTPUTo THEY
MAY BE USED TO GENERATE IMMEDIATE OUTPUT, OR '1 0 STORE AN
1

IMAGE FOR LA'1'ER PRINTINGo THE TWO FORMS ARE:


PATTERN DFT TABLE
PATTERN EFT TABLE
AND
IMAGE+PATTERN DFT TABLE
IMAGE+PATTERN EFT TABLE
'THESE FUNCTIONS WORK PROPERLY ONLY WITH 1-0RIGIN INDEXINGo
RIGHT ARGUMENT: AN ARRAY TO BE FORMED.
IT MUST BE NUMERICAL, AND OF RANK ~ 3. THE FIRST
PLANE OF A 3 -DIMENSIONAL ARRAY WILL BE TREA'1'ED AS A
MA'1 1RIX, AND ALL OTHER PLANES WILL BE DISREGARDED 0

ARRAYS OF HIGHER RANK WILL BE SIGNALLED AS A 'RANK


PROBLEM 0 '

LEFT ARGUMENT: ONE OR MORE INTEGERS TO CON'1'ROL THE FORMAT.


FRACTIONAL NUMBERS WILL BE SIGNALLED AS A 'DOMAIN
PROBLEM 0 '

A SINGLE INTEGER~
DFT: SPECIFIES THE NUMBER OF DIGITS TO THE RIGHT OF
'PHE DECIMAL POINT IN DECIMAL FORMAT.
EF'11~ SPECIFIES THE NUMBER OF SIGNIFICANT DIGITS IN
EXPONENTIAL FORMATo ONE DIGIT ALWAYS APPEARS TO THE
LEFT OF THE DECIMAL POINTo COLUMNS WILL BE SPACED
UNIFORMLY, WITH SPACING SUCH THAT THERE WILL BE TWO
SPACES BETWEEN THE CLOSEST NUMBERS.
A. PAIR OF IN'l'EGERS: .THE FIRST SPECIFIES THE TOTAL
NUMBER OF SPACES TO BE ALLOCATED TO EACH COLUMN, AND
THE SECOND IS USED AS ABOVE.
DFT: THE FIRST NUMBER MUST BE AT LEAST TWO LARGER
'l'HAN THE SECOND
0

EFT~ THE FIRST NUMB8R MUST BE AT LEAS'l' SIX LARGER


THAN THE SECONDo IF THE LEFT NUMBER IS TOO SMALL,
'THIS WILL BE SIGNALLED AS' A 'DOMAIN PROBLE'M. '
MORE THAN ONE PAIR OF INTEGERS: THERE MUST BE ONE PAIR
FOR EACH COLU~N OF OUTPUT (OR EACH ELEMENT OF A VEC-
TOR)0 EACH PAIR WILL BE INTERPRETED AS ABOVE, AND
WILL APPLY TO THE LAYOUT OF THE CORRESPONDING COLUMN.
IF THE NUMBER OF PAIRS DOES NOT MATCH THE NUMBER OF
COLUMNS, THIS WILL BE SIGNALLED AS A 'LENG.TH PROBLEM.'

4.3
HOWPLOT

THE FUNCTION PLOT WILL GRAPH ONE OR MORE FUNCTIONS


SIMULTANEOUSLY, AUTOMATICALLY SCALING THE VALUES TO FIT
APPROXIMATELY WITHIN SCALE DIMENSIONS SPECIFIED BY THE USER 0

IT WILL WORK ONLY IN i-ORIGIN INDEXING.

THE FORM IN WHICH PLOT IS USED IS~

SCALESIZE PLOT FUNCTION


LEFT ARGUMENT: ONE OR TWO NUMBERS o

THE FIRST NUMBER SPECIFIES THE APPROXIMATE SIZE OF THE


VERTICAL AXIS AND THE SECOND NUMBER DOES THE SAME
FOR THE HORIZONTAL AXISo

IF ONLY ONE NUMBER IS SUPPLIED, IT IS APPLIED TO BOTH


AXES0

THERE IS NO BUILT-IN LIMIT TO THE DIMENSIONS, AND A


HORIZONTAL AXIS LARGER THAN THE WORKSPACE WIDTH WILL
CAUSE SOME POINTS TO BE PRINTED ON THE NEXT LOWER
LINEo
RIGHT ARGUMENT: A RECTANGULAR ARRAY WITH RANK:=; 3.

SCALAR: WILL BE TREATED AS A VEC'liOR OF LENGTH ONE 0

VECTOR: WILL BE PLOTTED AS ORDINATE AGAINST ITS OWN


INDICES AS ABSCISSAo
MATRIX: THE LEFTMOST COLUMN WILL BE TAKEN AS THE
ABSCISSA AND ALL OTHER COLUMNS WILL BE PLOTTED AS
ORDINA'PESo A DIFFERENT PLOTTING SYMBOL UP TO THE
NUMBER OF SYMBOLS AVAILABLEWILL BE USED FOR EACH
COLUMNo IN CASE TWO ORDINATES HAVE A COMMON POINT,
THE SYMBOL FOR THE COLUMN FURTHES'll TO THE' RIGHT WILL
BE USED 0

3-DIMENSIONAL ARRAY: THE FIRST PLANE WILL BE PLOTTED


AS A MATRIX, AND ALL OTHER PLANES WILL BE DISREGARDED.

4.4
AUXILIARY FUNCTIONS: THE FUNCTIONS AND AND VS CAN BE
USED TO GENERATE THE RIGHT ARGUMENT IN THE PROPER FORM
FOR PLOTo FOR EXAMPLE~

20 PLO'P Z AND Y VS X

PLOT CHARACTERS: THE SYMBOLS USED ARE ASSIGNED TO THE


VARIABLE EQ IN LINE 1 OF PLOT. THE ALPHABET
SUPPLIED IS 'o*ov~D' THIS ALPHABET MAY BE EXTENDED
0

AND MODIFIED AS DESIRED, USING THE NORMAL


FUNCTION-EDITING PROCEDURES: EITH ER CHANGE L1 NE 1 OF
THE FUNCTION, OR DELETE IT AND INDEPENDENTLY SPECIFY
A. VALUE FOR EQo

HISTOGRAMS: PLOT CAN BE USED TO GENERATE HISTOGRAMS BY


SETTING THE VARIABLE HS TO 1 IN LINE 2 OF THE
FUNCTION. ALTERNATIVELY, LINE 2 CAN BE DELETED, AND
1l.3. CAN BE SET EXTERNALLY 0

)LOAD 1 APLCOURSE
APLCOURSE' SAVED 07/19/68
)FNS
B1X CHECK DESCRIBE DIM DRILL DYAD1 DYAD2
EASY EASYDRILL FORM FUNDRILL GET INPUT
INTER LOG QUES RANDOM REDSCAPATCH REPP
SETPARAMETERS TEACH TRACE
DESCRIBE

THE MAIN FUNCTIONS IN THIS LIBRARY WORKSPACE ARE:

TEACH
EASYDRILL

ALL OTHER FUNCTIONS ARE SUBFUNCT10NS AND ARE NOT


SELF-CON'1.'AINED 0

SYNTAX DESCRIPTION
TEACH AN EXERCISE IN APL FUNCTIONS USING SCALARS
AND VECTORS 0 THE FUNCTION PRIN'1. OUT THE 1S

CHOICES AND OPTIONS AVAILABLEo EXAMPLES


ARE SELECTED AT RANDOM WITH A RANDOM
STARTING POIN.T.
E.ASYDRILL THIS IS THE SAME AS TEACH EXCEPT THAT THE
PROBLEMS SELECTED ARE GENERALLY SIMPLER IN
STRUCTUREo PROBLEMS INVOLVING VECTORS OF
LENGTH ZERO OR ONE ARE EXCLUDED.

4.5
NOTE: FOR EITHER FUNCTION, A RESPONSE OF - PLEASE - WILL
DISCLOSE THE PROPER ANSWERo A RESPONSE OF - STOP - WILL
TERMINATE THE DRILLo

TEACH
ARE YOU ALREADY FAMILIAR WITH THE INSTRUCTIONS? (TYPE
Y FOR YES AND N FOR NO o )

THIS IS AN EXERCISE IN SIMPLE APL EXPRESSIONS. YOU WILL


FIRST HAVE THE OPPORTUNITY TO SELECT THE FEATURES YOU WISH
TO BE DRILLED INo THE EXERCISE THEN BEGINS o FOR EACH
PROBLEM YOU MUST ENTER THE PROPER RESULT. ANSWERS WILL
CONSIST OF SCALAR INTEGERS IF EXERCISES WITH VECTORS ARE NOT
DESIRED; O']'HERWISE ANSWERS WILL CONSIST OF SCALARS OR
VECTORSo A VECTOR OF LENGTH ZERO REQUIRES THE RESPONSE 10,
A VECTOR OF LENGTH ONE REQUIRES THE RESPONSE X, WHERE X IS
THE VALUE OF THE ELEMENT. YOU HAVE THREE TRIES FOR EACH
PROBLEM o TYPE STOP AT ANY TIME TO TERMINATE THE EXERCISE
AND PRODUCE A RECORDING OF YOUR PERFORMANCE. TYPING
STOPSHORT WILL TERMINATE THE EXERCISE BUT WILL NOT PRODUCE
A RECORD OF PERFORMANCE TYPING PLEASE 0FOR ANY PROBLEM
WILL LET YOU PEEK AT THE ANSWERSo TYPE Y UNDER EACH
FUNCTION FOR WH1'CH YOU WANT EXERCISE:

SCALAR DYADIC FUNCTIONS


+-xf*rL <::;=~>~! I AV$tN"I'
YYYYY Y
SCALAR MONADIC FUNCTIONS
+-xfrL! I'"""
YY
TYPE Y IF EXERCISES ARE TO USE VECTORS, N OTHERWISE
N
6x 3
0:
18

0:
2
TRY AGAIN
0:
3
0+7
0:
STOPSHORT

4.6
)LOAD 1 WSFNS
WSFNS SAVED 07/20/68 31 025 023

)FNS
DELAY DESCRIBE DIGITS ORIGIN SETLINK SFEI WIDTH

DESCRIBE

THE FUNCTIONS ORIGIN, WIDTH, AND DIGITS ARE EACH


SIMILAR TO THE COMMAND OF THE SAME NAME, EXCEPT THAT EACH IS
A FUNe'JlION RATHER THAN A COMMAND AND MAY ThEREFORE BE USED
WITHIN OTHER FUNCTIONS EACH HAS AN EXPLICIT RESULT WHICH
0

IS THE PREVIOUS VALUE OF THE RELEVANT SYS'PEM PARAMETER.

FOR EXAMPLE, THE FOLLOWING FUNCTION:

VF X
[ 1J X+ 0 RIGI
N X
[2J G
[3J X+ORIGIN xv

WILL EXECUTE THE FUNCTION G WITH WHATEVER INDEX ORIGIN IS


SPECIFIED BY THE ARGUMENT OF F, AND WILL RESTORE THE INDEX
ORIGIN TO THE VALUE THAT IT HAD BEFORE THE EXECUTION OF F.

THE F 0 LL 0 WING FUN CTIONS ARE Ai» J AVAI LABLE :

!2E.§'QB.l.E.l.l.Qli.
Z+-SETLINK X SETS THE VALUE OF THE LINK IN THE CHAIN OF
NUMBERS GENERATED IN THE USE OF .THE ROLL AND
DEAL FUNCTIONS THE EXPLICIT RESULT PRODUCED
0

BY SETLINK IS THE PREVIOUS VALUE OF THE LINK o

TH-g RESULTS PRODUCED BY THE ROLL AND DEAL


FUNCTIONS ARE NOT THE LINKS THEMSELVES, BUT
RATHER SOME FUNCTION OF THEM THE LENGTH OF 0

THE CHAIN (BEFORE REPETITION) IS -1+2*31.

DELAY X DELAYS EXECUTION FOR X SECONDS o

SFEI X SETS THE SIGNAL MESSAGE FOR EVALUATED INPUT


(SEE THE SECTION ON INPUT AND OUTPUT, PART 3
OF THE APL\360 USER'S MANUAL)o THE ARGUMENT
MUST BE A LINE OF NO MORE THAN 7 CHARACTERS 0

4.7
)LOAD 1 TYPEDRILL
TYPEDRILL SAVED 07/14/68
)FNS
DESCRIBE IN INSTRUCTIONS MATCH PR'l' QUERY
S'TATISTICS TIME TYPEDRILL WS

DESCRIBE
THE MAIN FUNCTION IN THIS WORKSPACE IS TYPEDRILL; ALL
OTHERS ARE SUBFUNCT10NS. TO USE IT, SIMPLY ENTER

TYPEDRILL

TYPEDRILL IS A TIMED TYPING EXERCISE. THE SYSTEM


RESPONDS WITH THE STATEMENT 'YOU ARE IN CONTROL STATE'.
FOUR COMMANDS ARE AT YOUR DISPOSAL: ENTER, DRILL, STAT, AND
STOP. ENTERING ONE OF THEM BRINGS YOU INTO THAT STATE~
ENTER: YOU MAY ENTER ONE-LINE SENTENCES OR
EXPRESSIONS ON WHICH YOU WISH TO BE DRILLED. ENTERING
A BLANK LINE (CARRIAGE RETURN ONLY) RETURNS YOU TO THE
CONTROL STATE.

DRILL: ONE OF THE LINES ENTERED VIA THE ENTER STATE IS


SELECTED A'll RANDOM AND PRINTED. YOU ARE THEN EXPECTED
TO ENTER THE SAME LINE. IF IT IS CORRECT, THE TIME
TAKEN IS PRINTED (IN SECONDS), IF NOT YOU ARE ASKED TO
RETYPE IT. A BLANK LINE CAUSES RETURN TO THE CONTROL
STATE.

STAT: THE ACCUMULATED STATISTICS ARE PRINTED. THE


HORIZONTAL AXIS SHOWS THE TRIAL NUMBERS AND THE
VERTICAL SHOWS THE TIME IN SECONDS. A VERTICAL ARROW
INDICATES THAT THE TIME EXCEEDED THE LIMITS OF THE
GRAPH. THE RE'l'URN TO THE CONTROL STA'l7E IS AUTOMA'l7I C.

STOP: STOPS THE DRILL AND PRINTS THE STATISTICS.

4.8
TYPEDRILL
CONTROL WORDS ARE: ENTER, DRILL, STAT, AND STOP.
Y() U ARE' INC 0 NTR 0 L S TA l' E
ENTER
NOW IS THE TIME FOR ALL GOOD MEN TO COME TO
I SING OF OLAF GLAD AND BIG
X-E-I rpxQ+Y*R~ 5
YOU ARE IN CONTROL ST A.1'E
DRILL
NOW IS THE' TIME FOR ALL GOOD MEN TO COME TO
NOW IS THE TIME OFR ALL GOOD MEN TO COME TO
A
NOW IS THE TIME FOR ALL GOOD MEN TO COME TO
115 09

X-E-I r pxQ+Y*R~ 5
X-f-I r pxQ+Y*R~ 5
19 09

I SING OF OLAF GLAD AND BIG


YOU ARE' IN CONTROL STA'l'E
S.TOP

4.9
Appendix A

SAMPLE TERMINAL SESSION

)177E)
010) 1903:2 036 07/03/68 JANET

A P L \ 360

FUNDAMENTALS

3x4 Entry automatically indented


12 Response not indented
X+-3x4 X is assigned value of
the expression
x
1:2 Value of X typed out
Y+- - 5 Negative sign for negative
constants
X+Y
7
Exponential form of constant
1 044

P+-1 :2 3 4 Four-element vector


pxp Functions apply element by element
1 4 9 1(3
pxY Scalar applies to all elements
5 10 :15 20
Q+-'CATS' Character constant (4-element
Q vector)
CATS
YZ+-5 Multi-character names
Y~1+-5
YZ+Y1~1
10
3+4x5+6 Correction by backspace
v and linefeed
+5+6
18
X+-3
Y+-4
(XXY)+4
16
Executed from right to left
24

A.I
x Y Entry of invalid expression
SYNTAX ERROR Shows type of error committed
X Y Retypes invalid statement with
1\ caret where execution stopped
XY Multi-character name (not Xxy)
VALUE ERROR
XY XY had not been assigned a value
1\
SCALAR FUNCTIONS

Dyadic maximum

12
Monadic ceiling
24
X+15 Index generator function
X
1 2 345
1 0 Empty vector
prints as a blank line
Y+5-X All scalar functions extend
Y to vectors
43210
Xry
4 334 5
X~y Relations produce
1 1 0 0 0 logical (0 1) results
01 Pix1
3 0141592654

0+1 2 Pi+1 2
3 0141592654 1 0570796327

X+45 90
oX+180 Conversion of X to radians
0 07853981634 1.570796327
101 Sin 1
0 08418709848

201 2 Cos 1 2
0 05403023059 0 04161468365

301 Tan 1
1 0557407725

-301 Arctan 1
0 07853981634

30-3017 Tan Arctan 1 2 3 4 5 6 7


1 2 3 4 567
Y+1 2
40Y
1 0414213562 2 0236067977

Oo+y
o 0 08660254038

701 2 Tanh 1 2
0 0761594156 0 09640275801

-70701 2 Arctanh Tanh 1 2


1 2

A.2
DEFINED FUNCTIONS

\/Z+·X F Y Header (2 args and result)


[1 J Z+((X*2)+.Y*2)*oS Function body
[2J \/ Close of definition
3 F' 4 Execution of dyadic function F
S
P+7
Q+(P+1)F P-1 Use of F with expressions
Q as arguments
10
4x 3 F 4
20
\/ B~-G A G is the signum function
[ 1J B+(A>O)-A<O A and B are local variables
[ 2J \/
G 4·
1
G 6
1

1
\/H A Like G but has no explicit result
[1J P+(A>O)-A<O P is a global variable
[2J \/
H 6
P
1
Y+H-6 H has no explicit result
VALUE ERROR and hence produces a value
Y+H -6 error when used to right
of assignment
\/Z+-FAC N;.I FAC is the factorial function
[1J Z+1
[2J I+O
[3J L1:I+I+1 Ll becomes 3 at close of def
[4J -+oxl.I>N Branch to 0 (out) or to next
rs i Z+ZxI
[6J -+L1. Branch to Ll (that is, 3)
[ 7J \/
FAC 3
6
FAC S
120
T!1F'AC+3 S Set trace on lines 3 and 5 of FAC
X+FAC 3
FAC[3J 1 Trace of FAC
FAC[SJ 1
FAC[3J 2
FAC[SJ 2
FAC[3J 3
FAC[SJ 6
FAC[3J 4
T!1F'AC+O Reset trace control

A.3
HECHANICS OF
FUNCTION DEFINITION

VG+-M GCD N Greatest common divisor


[ 1 J G+-N function based on the
[ 2J M+-MIN Euclidean algorithm
[ 3J -7-"4xM:;t:.Q
[ 4 J [lJG+-M Correction of line 1
[ 2 J [ 4 IN+-G Resume with line 4
[ 5J [10J Display line 1
[ 1 J G+-M
[ 1J [OJ Display entire GCD Function
V G+-M GCD N
[ 1J G·+-M
[ 2J M+-MIN
[ 3J -7-"4xM:;t:.Q
[ 4J N+-G
V Close of display, not close of def
[ 5 J -7-"1 Enter line 5
[ 6 J V Close of definition
36 GCD 44 Use of GCD
4 4 is GCD of 36 and 44
VGCD Reopen def (Use V and name only)
[ 6 J [401JM,N Insert between 4 and 5
[ 4 0 2 J [OJ Display entire function
V G+-M GCD N
[ 1 J G+-M
[ 2J M+-MIN
[ 3J -7-"4xM:;t:.Q
[ 4 J N+-G
[ 4,,1 J M,N Fraction stays until close of def
[ 5J -7-"1
V End of display
[ 6J V Close of definition
36 GCD 44
8 36 Iterations printed by
4 8 line 5 (was line 4.1)
4 Final result
VGCD[DJv Reopen, display, and close GCD
V G+-M GCD N
[ 1 J G-<,-M
[ 2J M+-MIN
[3J -7-"4 xM:;t:. Q
[4J N+-G
[ 5J M,N Line numbers have been
[ 6J -7-"1 reassigned as integers
V Close (Even number of V's in all)
VGCD Reopen definition of GCD
[ 7J [ 5J Delete line 5 by linefeed
A
V Close definition

A.4
VZ+ABC X A function to show line editing
[1] Z+(33 xQ+(R x 5 ) - 6 A line to be corrected
[2] [ 1[]9 J Initiate edit of line I
[ 1] Z+(33xQ+(R x 5 ) - 6 Types line, stops ball under 9
/ 1 /1 Slash deletes, digit inserts spaces
[ 1] Z+(3 xQ)+(T x 5 ) - 6 Ball stops at first new
[2 ]I V space. Then enter) T
FAC 5 FAC still defined
120
)ERASE FAC Erase function FAC
FAC 5 Function FAC no longer exists
SYNTAX ERROR
FAC 5
A
VZ-f-BIN N An (erroneous) function for
[1J LA~Z+(Z,O)+O,Z binomial coefficients
[2J -+LAxN"?pZV
B1N 3
VALUE ERROR
BIN[1J LA:Z+(Z,O)+O,Z Suspended execution
A
Z+1 Assign value to Z
-+1 Resume execution
1 3 3 1 Binomial coefficients of order 3
BIN 4
VALUE ERROR Same error (local variable Z
BIN[1] L1:Z+(Z,O)+O,Z does not retain its value)
A
VBIN[o1JZ+1V Insert line to initialize z
)SI Display state indicator
BIN[1J * Suspended on line I of BIN
-+1 Resume execution (BIN now correct)
1 1+ 6 4 1
VBIN[OJV Display revised function
V Z+BIN N and close definition
[1J Z+1
[2J LA:Z+(Z,O)+O,Z
[3J -+LAxN"?pZ
S~BIN+2 Set stop on line 2
Q+BIN 3 Execute BIN

BIN[2J Stop due to stop control


Z Display current value of Z
1
-+2 Resume execution

BIN[2J Stop again on next iteration


-+2 Resume

BIN[2J Stop again


-+0 Branch to 0 (termi.nate)

A.5
INPUT AND OUTPUT

\/MULTDRILL N;Y;X A multiplication drill


[ 1 J Y+-?N pN random integers
[ 2J Y Print the random factors
[ 3J X+-D Keyboard input
[4J -+OX1X='S' Stop if entry is the letter S
[ 5J -+lX=X/Y Repeat if entry is correct product
[ 6J 'WRONG, TRY AGAIN' Prints if preceding branch fails
[ 7J -+3\/ Branch to 3 for retry
MULTDRILL 12 12 Drill for pairs in range 1 to 12
2 10
D: Indicates that keyboard entry
37 is awai ted
WRONG, TRY AGAIN
0:
20
6 7
D:
'S' Entry of letter S stops drill
\/Z+-ENTERTEXT Example of character ([!]) input
[ 1J Z+-' , Make Z an empty vector
[2J D+-pZ D is the length of Z
[3J Z+-Z,[!] Append character keyboard entry
[4J -+2xD~pZ Branch to 2 if length increased
[ 5] \/ (i.e., entry was not empty)
Q+-ENTE'RTEXT
THIS IS ALL Keyboard
CHARACTER INPUT entries
Empty input to terminate
Q Display Q
THIS IS ALL CHARACTER INPUT
N+-5
'NOTE: l';N;' IS ';IN Mixed output statement
NOTE:15 IS 1 2 3 4 5

RECTANGULAR ARRAYS

P+-2 3 5 7
pP Dimension of P
4
T·~' OH MY' Character vector
p.T
5
P,P Catenation
2 3 5 7 2 3 5 7
T,T
OR MYOH MY
T,P
DOMAIN .ERROR Characters cannot be catenated
T,P wi th numbers
1\

A.6
M+2 3p2 3 5 '7 11 13 Reshape to produce a 2x3 matrix
M Display of an array of rank >1
is preceded by a blank line
:2 3 5
'7 11 13
2 4p T A 2x4 matrix of characters

OH M
YOH
6pM A matrix reshaped to a vector
2 3 5 '7 :1.1 13
,M Elements in row-major order
2 3 5 7 :1.1 13
P+,M
P[3J Indexing (third element of p)
ot;
P[l 3 5J A vector index
2 5 11
P[13J The first three elements of P
2 3 5
P[ pP J Last element of P
:L3
M[1;2J Element in row 1, column 2 of M
3
M[l;J Row 1 of M
1")
L.. 3 5
M[l 1;3 2J Rows 1 and 1, columns 3 2

5 3
5 3
A+' ABCDEFGHIJKLMNOPQ' The alphabet to Q
A [MJ A matrix index produces
a matrix result
BeE
GKM
A[M[l 1;3 2JJ

BC
EC
M[1;J+15 3 12 Respecifying the first row of M
M

15 3 12
7 11 13

A.7
Q+-3 1 5 2 4 6 A permutation vector
P[QJ Permutation of P
5 2 11 3 7 13
Q[Q] A new permutation
5 3 4 1 2 6
P[3] Present index origin is 1
5
)ORIGIN 0 Set index origin to 0
WAS 1
P[3]
7
P[O 1 2 ] First three elements of P
2 3 5
1 5 Result of index generator
0 1 2 3 4 begins at origin
)ORIGIN 1
WAS 0
1 5
1 2 3 4 5

FUNCTIONS ON ARRA.YS

·V+-? 3 p 9 Vector of 3 random integers (1-9)


M+-?3 3p9 Random 3 by 3 matrix
N+-? 3 3 p 9 Random 3 by 3 matrix
V
217
M

7 9 4
5 8 1
1 5 7
N
1 4 1
4 7 6
9 8 5
M+N Sum (element-by-element)

8 13 5
9 15 7
10 13 12

A.8
MrN Maximum

7 9 4
5 8 ' 6
9 8 7
M5N Comparison

0 0 0
0 0 1
1 1 0
+/V Sum-reduction of V
10
x/V Product-reduction
14
+/ [ 1 JM Sum over first coordinate of M
13 22 12 (down columns)
+/ [ 2 JM Sum over second coordinate of M
(over rows)
20 14 13
+/M Sum over last coordinate
20 14 13
riM Maximum over last coordinate
987
X+1 ry 5
+/(1 20X)*2 Sin squared plus Cos squared
1
0/1 2,X Sin Cos X
0 007067822453

Y+o/O 2:,X ( 1- ( COS X) *2 ) * 0 5


Y
0 09974949866

Y=10X An identity
1
Mt 0 <N Ordinary matrix (+ox inner)
product
79 123 El1
46 84 :;8
84 95 66
Mt o5N An inner product
111
111
2 3 2
Mt 0 xV +ox inner product with vector
51 25 56 right argument

A.9
V
2 1 7
V oX 1 5 Outer product (times)

2 4 6 8 10
1 2 3 4 5
7 14 21 28 35
Vo 0 s 19 Outer product

0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 1 1 1
v-. xM An outer product of rank 3

14 18 8
10 16 2
2 10 14
A blank line between planes
7 9 4
5 8 1
[-
1 o 7

49 63 28
35 56 7
7 35 49

MIXED FUNCTIONS

Q+?10p 5 A random 10 element vector


Q (range 1 to 5)
1 4 3 4 5 4 2 1 4 2
+/[1]Qoo=15 Ith element of result is number
2 2 1 4 1 of occurences of the
value I in Q
2 1~M Ordinary transpose of M

7 5 1
9 8 5
4 1 7
~M Ordinary transpose of M (monadic)

7 5 1
9 8 5
4 1 7

A.IO
T+2 3 4Pl24 An array of rank 3
T

1 2 3 4
5 6 7 8
9 10 11 12

13 14 15 16
17 18 19 20
21 22 23 24

3 1 2G(T Transpose of T (dimension


of result is 3 4 2)
1 13
2 14
3 15
4 16

5 17
6 18
7 19
8 20

9 21
10 22
11 23
12 24
1 1G(M Diagonal of M
787
1 1 2G(T Diagonal section in first
two coordinates of T
1 2 3 4
17 18 19 20
Xf-O(0,15)+6
)DIGITS 4 Set number of output digits to 4
W;1S 10
G(1 2 3 0
00X

O.OOOEO ::LoOOOEO OoOOOEO Table of sines, cosines,and


50000E-1 8,,660E-1 50774E-1 tangents in intervals
80660E-1 50000E-1 10732EO of 30 degrees
1.0aOEO ::Lo744E-16 50734E15

8 0660E-1 ~)oOOOE-1 1.732EO


5.000E-1 El o660E-1 5.774E-1

A.II
Q
1 4 3 4 5 4 2 1 4 2
3¢Q Rotate to left by 3 places
4 5 4 2 1 4 2 1 4 3
-3¢Q Rotate to right by 3 places
1 4 2 1 4 3 4 5 4 2
0 1 2¢[1]M Rotate columns by
different amounts
7 8 7
5 5 4
1 9 1
-2¢[2]M Rotation of rows all
by 2 to right
9 4 7
8 1 5
5 7 1
1 2 3¢M Rotation of rows

9 4 7
1 5 8
1 5 7
¢Q Reversal of Q
2 4 1 2 4 5 4 3 4 1

¢[ 1 JM Reversal of M along
first coordinate
1 5 7
5 8 1
7 9 4
<pM Reversal along last coordinate

4 9 7
1 8 5
7 5 1

A.12
U+Q>4
U
o 0 0 0 1 0 0 000
UIQ Compression of Q by logical
5 vector U
( "'U ) I Q Compression by not U
1 4 344 2 142
+IUIQ
5
1 0 1/[1]M Compression along first
coordinate of M
794
157
1 0 11M Compression along last
coordinate
7 q.
5 1
1 7
(,M>5)j,M 1M is 7 9 4 5 8 1 1 5 7
7 Sl 8 7 All elements of M which exceed 5
v'+l 0 1 0 1
V\ 1 3 Expansion of iota 3
10203
V\M Expansion of rows of M

7 0 9 0 4
5 0 8 0 1
10507
V\ 'ABC' Expansion of literal vector
ABC inserts spaces
10.11 7 7 6 Base 10 value of vector 1 7 7 6
1776
8.11 7 7 6 Base 8 value of 1 7 7 6
1022
(4pl0)T1776 4 digit base 10 representation
1 7 7 6 of number 1776
(3pl0)T:L776 3 digit base 10 representation
776 of 1776
10 10T1776
7 6
10T1776
6
24 60 60.11 3 25 Mixed base value of 1 3 25
3:305 (time radix)
24 60 60T3805 Representation of number 3805
1 3 25 in time radix
2.11 0 1 1 0 Base 2 value

A.13
M
7 9 4
5 8 1
1 5 7
)ORIGIN 0

WAS 1
M[2;0] Indexing of matrix in a-origin.
1 Note relation to indexing of
( ,M)[(pM).l2,0] ravel of M
1
)ORIGIN 1 Restore I-origin
WAS 0
P
1-
2 3 J 7 11 13
P17 Index of 7 in vector P
4 7 is 4th element of P
P16 6 does not occur in P, hence
7 result is l+pP
P14 5 6 7
7 3 7 4
Q+5 1 3 2 4 A permutation vector
R+Q 1 1 PQ R is the permutation inverse to Q
R
24351
Q[R]
1 2 345
A+'ABCDEFGHIJKLMNOPQ'
A+A, , RSTU VWXY Z '
A A is the alphabet
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A1 ' C' Rank of letter C in alphabet is 3
3
J+Al 'CAT'
J
3 1 20
A[J]
CAT

A.14
M+3 5p'THREESHORTWORDS' A matrix of characters
M

THREE
SHOR'JI
WORDS
J+AlM Ranking of M produce s a matrix
J
20 8 18 5 5
19 8 15 18 20
23 15 18 4 19
A[J] Indexing by a matrix produces
a matrix
THREE
SHORT
WORDS
3?5 Random choice of 3 out of S
512 without replacement
6?5
DOMAIN ~'Rl?OR
6?5
A
X+8?8 A random permutation vector
X
4 6 7 2 5 183
~X Grading of X
6 4 8 1 5 2 3 7
X[!X] Arrange in ascending order
1 2 3 4 5 6 7 8
X[VX] Arrange in descending order
876 5 432 1
V+ A E: ' NOW IS TH E TIME' Membership
'01'[1+V]
00001001100011100011001000
VIA
EHIMNOSTW
(18)E3 7 5
o 0 1 0 1 0 1 0

A.IS
Appendix B

ADVANCED EXAMPLES

This section presents a set of examples less elementary


i:han those of Appendix A. These examples are all contained
in Workspace ADVANCEDEX of Library 1. A user may therefore
load, use, and trace any of the functions as an aid to
understanding their behavior. Displays of intermediate
results may a.lso be inserted. For example, the statement

P+(P,O)+O,P

occurring in a function could be changed (perhaps by the use


of line editing) to the following form:

D+P+(D+P,O)+D+O,P

Bach execution of the statement will now perform as before,


except that each of the results O,P and P,o and P will be
t:yped out as well (in that sequence).

Programming techniques can be learned from a similar


study of any well-written set of functions. All of the
wo rk sp ace s of library 1 may be used as a source of functions
for such study.

The index origin in the workspace AD VA NCEDE X is set to


1..

)LOAD 1 ADVANCEDEX
AD VANCBDEX SA VED 07/20/68 28 012 010

)FNS
A.H ASSOD BIN COMB DTH ENTER F FC
CC GCD GCV HILB HTD IN INV INVP
IN1 LFC LOOKUP PACK PALL PER PERM PO
POL POLY POLYB RESET TIME TRUTH UNPACK ZERO
)VARS
DAH DASSOC DBIN DCOMB DDTH DENTER DESCRIBE
DF DFC DGC DeCD DGCV DHILB DHTD DIN
DINV DINVP DIN1 DLFC DLOOKUP DPACK DPALL DPER
DPERM DPO DPOL DPOLY DPOLYB DTIME DTRUTH DUNPACK
DZERO TIMER

DESCRIBE

EACH OF THE VARIABLES OF THIS WORKSPACE WHICH BEGINS WITH THE


LE'TTER D IS THE DESCRIPTION OF THE FUNCTION WHOSE NAME IS
OBTAINED BY REMOVING THE Do FOR FURTHER DETAILS SEE APPENDIX
B OFTHE' A P L \ 360 USE R 'S MA NUAL
0

B.I
DPACK
THE FUNCTIONS PACK AND UNPACK ILLUSTRATE THE USE OF THE
ENCODE AND DECODE FUNCTIONS IN TRANSFORMING BETWEEN A FOUR-
NUMBER ENCODING OF SERIAL NUMBER (1 TO 9999), 'MONTH, DAY,
AND YEAR, AND A SINGLE-NUMBER ENCODING OF THE SAME DATAo
V' PACK[ 0]\7
\7 Z+PACK X
[1] Z+ 10000 12 31 100 iX-1
\7

\7UNPACK[O]\7
\7 Z+UNPACK X
[1] Z+1+ 10000 12 31 100 TX
\7

P+PACK 2314 7 17 68
P
86063867
UNPACK P
2314 7 17 68
UNPACK PACK 2311 9 21 72
2311 9 21 72
PACK UNPACK 92137142
92137142
PACK 1 1 31 1
3000
UNPACK 3000
1 1 31 1

B.2
DENTER

'l'HE FUNCTIONS ENTER, LOOKUP, AND RESET ILLUSTRATE A METHOD


OF CONS']'RUCTING AND USING LISTS OF VARIABLE LENGTH DATA,
REPRESENTING EACH LIST BY A VECTOR OF CHARACTERS AND A
VECTOR OF INDICES. ENTER AND LOOKUP EACH REQUEST INPUP (BY ~)
UNTIL AN EMPTY VECTOR (CARRIAGE RETURN ALONE) IS ENTERED.

RESET RESETS LISTS (USE BEFORE EN1 7 E R AND LOOKUP).


ENTER ACCEP1'S SUCCESSIVE ITEMS OF NAMES AND DA1'A.
LOOKUP PR INTS DATA ASSOCIATED WI']'H EACH NAME ENTER ED 0

VENTER[OJI] VLOOKUP[OJI]
V EN'fER;X I] LOOKUP;X;J
[ 1J 'ENTER NAME' [lJ ,?'
[ 2] X+-,~ [ 2J X+', ~
[ 3J -~"OX10=pX [ 3J -+OX10=pX
[ 4] NAMES+NAMES,X [ 4J J+(((l+Pl)--l+Pl)=pX)/l-l+pPl
[5J Pl+-Pl, p NAMES [5J J+(NAMES[Pl[JJoo+lpX]A o = X ) / J
[ 6] 'ENTER DATA' [ 6J -+(0 1 =pJ)/ 10 8
[ 7J DATA+DATA , ~ [7J -+l,PU+'MORE THAN ONE SUCH NAME'
[8J P2+P2,pDATA [ 8J DATA[P2[JJ+l-/P2[1 0 +JJJ
[9J t, [ 9J -+1
[10J [10J 'NO SUCH NAME'
I] [llJ -+1
I]
I]RESET[OJI]
V RESET
[lJ NAMES+DATA+pPl+P2+0

RESET
E'NTER
ENTER NAME
J ARMSTRONG
0

ENTER DATA
PRESIDENT

ENTER NAME
H LEVINE
0

ENTER DATA
VICE-PFr'ESIDENT

EN1 1 B R NAME

LOOKUP
?
H LEVINE
Q

VICE-PRESIDEN.T
?
L YAVNER
0

NO SUCH NAME
?

B e3
DIN
THE FUNCTIONS IN AND IN1 TAKE TWO ARGUMENTS; THE FIRST IS A
WORD (IQEQ, A VECTOR) WHOSE OCCURRENCES IN THE SECOND
ARGUMENT ARE TO BE DETERMINED, THE RESULT IS A VECTOR OF
INDICES OF THE FIRST LETTER OF EACH OCCURRENCE. THE
FUNCTION IN DETERMINES dLL OCCURRENCES, WHEREAS IN1
DETERMINES ONLY ALL NON-OVERLAPPING OCCURRENCES BY FIRST
APPLYING THE FUNCTION IN AND THEN SUPPRESSING ALL OVERLAPS 0

VIN[OJv
V Z+A IN B;J
[lJ J+(A[lJ=B)/lpB
[2J J+(J~l+(pB)-pA)/J
[ 3J Z+ ( B [ J 0 0 + - 1 + 1 P A J 1\, =A ) / J
V
VIN1[OJv
V T+A IN1 B
[ 1J T+A IN B
[ 2J + 2 x J < p T+ ( ,. . , ( 1 P ']1) E J + 1 + ( ( p A) > I- /[ 1 J ( 2 , 1 + p T ) p T) 1 1 ) / T
V

W+' THE'
T+'THE MEN THEN WENT HOME Q '

W IN T
1 9
W IN1 T
1 9
'ABA' IN 'NOWABABABABABABABA'
4 6 8 10 12 14 16
'ABA' IN1 'NOWABABABABABABABA'
4 8 12 16

DTRUTH
THE FUNCTION TRUTH PRODUCES THE MA'l'RIX OF ARGUMENTS OF THE
TRUTH TABLE FOR N LOGICAL VARIABLES.

VTRUTH[OJv
V Z+TRUTH N
[1J z+2IL(-1+12*N)oQ+2*N-1N
V
TRUTH 3
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
( TRUTH 3)+oxcP2* 1+13
-
0 1 2 3 4 5 6 7

B.4
DGCD
THE FUNCTIONS GCD AND GC EACH EMPLOY THE EUCLIDEAN ALGORITHM
TO PRODUCE THE GREATEST COMMON DIVISOR. GCD EMPLOYS TWO
SCALAR ARGUMENTS, WHEREAS GC EMPLOYS A SINGLE ARGUMENT WHICH
IS EXPECTED TO BE A TWO-ELEMENT VECTOR 0

THE FUNCTION GCV YIELDS THE GREATEST COMMON DI VISOR OF ALL


ELEMENTS OF A VECTOR OF TWO OR MORE ELEMENTS.

VGCD[OJv
V Z+M GCD N
[lJ Z+M
[2J M+MIN
[3J N+Z
[4J ~O~M

VGC[OJv
V Z+GC M
[lJ ~O~l~M+~M[lJ,Z+I/M

VGCV[OJv
V Z+GCV W;A
t i : ~l~pW+Z,(A~O)/A+(Z+L/W)IW
V

84 GCD 90
6
90 GCD 84
6
GC 90 8 1+
6
CCV 90 84
6
GCV 90 84 105
3

DBIN
THE FUNCTION BIN PRODUCES ALL BINOMIAL COEPFICIEN.TS UP TO ORDER N
VBIN[OJv
V Z+BIN N
[lJ Z+L~(O,lN)oo!O,lN
V

BIN 4

1 0 000
1 1 0 0 0
1 2 1 0 0
1 3 310
1 4 6 4 1

:8.5
DPOLY
THE FUNCTIONS POLY, POL, PO, AND POLYB EACH EVALUATE A
POLYNOMIAL (OR POLYNOMIALS), WHOSE COEFFICIENTS ARE
DETERMINED BY THE FIRST ARGUMENT, AND WHOSE' POINT (OR
POINTS) OF EVALUATION IS DETERMINED BY THE SECOND ARGUMENT.
THE COEFFICIENTS ARE IN ASCENDING ORDER OF ASSOCIATED
POWERS 0

POLY SCALAR RIGHT ARGUMENT ONLYo


POL SCALAR RIGHT ARGUME NT ONLY (USES INNER PRODUC!]') 0

POLYB SCALAR RIGHT ARGUMENT ONLY (USES BASE VALUE).


PO APPLIES TO ARGUMENTS OF ANY RANK THE VECTORS ALONG o

THE FIRST COORDINATE OF THE FIRST ARGUMENT ARE THE


COEFFICIENTS OF THE POLYNOMIALS WHICH ARE EVALUATED
FOR EACH ELEMENT OF THE SECOND ARGUMENT.

VPOLY[OJv VPOLYB[OJV
V Z+C POLY X V Z+C POLYB X
[ 1J Z++/CxX* 1+1P,C [1J Z+Xl<PC
V V

VPOL[OJV VPO[OJv
V Z+C POL X V Z+C PO X
[ 1J Z+(X* - 1+1P,C)+.xC [1J Z+(Xo o*
- 1+11ppC)+oxC
V V

C+1 2 3 4
C POLYB 3
142
(C POLY 3)I\Q=(C POLYB 3) , (C POL 3),C PO 3
1
C PO 1 2 3 4 5 6
10 49 142 313 586 985
O+M+ts?BIN 5
1 1 1 1 1 1
0 1 2 3 4 5
0 0 1 3 6 10
0 0 0 1 4 10
0 0 0 0 1 5
0 0 0 0 0 1

LM PO 1 6

1 2 4 8 16 32
1 3 9 27 81 243
1 4 16 64 256 1024
:1 5 25 125 625 3125
1 6 36 216 1296 7776
:1 7 49 343 2401 16807

B.6
DTIME
THE FUNCTION TIME YIELDS THE AMOUNT (IN MINUTES, SECONDS,
AND 60THS OF A SECOND) OF CPU TIME USED SINCE ITS LAST
PREVIOUS EXECUTION. IT IS USEFUL IN MEASURING THE EXECUT10N
'TIMES OF OTHER FUNCTIONS THE VARIABLE 'TIMER' IS ASSIGNED
0

'jIHE VALUE OF THE CUMULATIVE CPU TIME AT EACH EXECUTION OF


THE FUNCTION TIMEo
VTIME[OJV
V Z+TIME;T
[lJ Z+ 60 60 60 T(T+I21)-TIMER
[2J TIMER+T

DCOMB

THE FUNCTION COMB EMPLOYS R"6'CURSIVE DEFINITION TO PRODUCE A


2!N BY 2 MArpRIX OF ALL POSSIBLE PAIRS OF ELEMENTS FROM lN 0

'j'HE FUNCTION FC SHOWS' AN ALTERNA'TE METHOD WHICH YIE LDS THE


SAME PAIRS BUT IN A DIFFERENT ORDER 0

THE FUNCTION LFC EMPLOYS FC TO GENERATE LETTER PA1"RS.


V COMB [OJv
V C+COMB N;A;B
[lJ -+OxlN<2
[2J -+OxlN=2 x1pC+ 1 2 p 1 2
[3J A+COMB N-1
[4J C+( (pA)+(N-1) ,O)p( ,A),,( IN-1)o 0 rO,N

VFC[OJv
V C+FC N ;.A;B
ri i B+(lN)oo+NpO
[2J A+(lN)oo+lN
[3J C+(2,NxN)p(,B)"A
[4J C+~(C[2;J~N)/C
V
VLFC[OJv
V Z+LFC N
[lJ Z+'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[FC NJ
V
TIME
0 0 35
TIME
0 0 2
COMB 4 FC 4 LFC 4

1 2 1 2 AB
1 3 1 3 AC
2 3 1 4 AD
1 4 2 3 Be
2 4 2 4 BD
3 4 3 4 CD
'PIME TIME TIME
0 0 :1.2 0 0 8 0 0 7

B.7
Z+COMB 15 Z+FC 15
pZ pZ
105 2 105 2
TIME TIME
0 1 4 0 0 29

DDTH

THE FUNCTIONS DTH, HTD, AND AH CONCERN HEXADECIMAL NUMBERS


LIMITl:./D TO 8 DIGITS AND EMPLOYING THE CHARACTERS
0123456789ABCDEFn NEGATIVE NUMBERS ARE REPRESENTED IN 2'S
COMPLEMEN2 1 FORM, WITH ANY OF THE CHARACTERS 8 THROUGH F IN
THE LEFTMOST POSITION (OF EIGHT)o LEADING ZEROS MAY BE
OMITTED 0

D'1'H CONVERTS DECIMAL TO HEXADECIMAL 0

HTD CONVERTS HEXADECIMAL TO DECIMALo


AH ADDS HEXADECIMAL NUMBERSo

VDTH[OJv
V R+DTH X
[ 1J R+ , ( , 0123456789 AB CD EF' ) [ 1 +( 8 p 16 ) T X J

VHTD[OJv
V R+HTD X
[1J R+((8-p,X)p'0'),X
L2 J R+L ( 16.L -1 + ' 0123456789 AB CD EP , 1 R) - ( 2 * 32 ) xR [1 J E ' 8 9AB CDE F'
[3J ~4x~A/XE'0123456789ABCDEF'
[ 4J R+' ,
[5 J 'NUMBER IS NOT HEX'

VAH[OJv
V R+A AH B
[1J R+DTH(H'1'D A)+HTD B

Z+DTH 1776
Z
000006FO
HTD Z
1776
Z AH Z
OOOOODEO
HTD Z AH Z
3552
HTD '000006FO'
1776
HTD '90000000'
1879048192
HTD '00049HFG'
NUMBER IS NOT HEX

B.8
DZERO

THE FUNCTION ZERO EMPLOYS THE METHOD OF FALSE POSITION TO


DETERMINE TO WITHIN A TOLERANCE TOL A ROOT OF THE FUNCTION F
LYIN:J BETWEEN THE BOUNDS B[lJ AND B[2Jo IT IS ASSUMED THAT
F B[lJ AND F B[2J ARE OF OPPOSITE SIGN. THE FUNCTION F IS A
SPECIFIC POLYNOMIAL, BUT CAN BE CHANGED TO ANY DESIRED
FUNCTION 0

VZERO[DJV'
V Z+TOL ZERO B;T
[lJ +OxlTOL~IT+F Z+005x+/B
[2J +1,B[2~(0<T)~0<F BJ+Z
V'

V'F[OJV'
V Z+F X
[lJ Z+ 20 18 3 5 1 PO X
\I

n-r- -4+ 19
3 2 -1 0 1 2 3 4 5
F X
169 12 29 20 3 4 7' 36 145
'TIME
o 1 1. 9
D+R+1E-6 ZERO 2 1
1 08451.21413

'l'IME
o 2 216
F R
7 01 L+1 4 0 81 4E 7'
'l'IME
o 0 :;;,
D+FD+R+1E-10 ZERO 1 2
1 026397094

-10813305062E 11
'TIME
o 3 46
D+FD+R+1E-6 ZERO 1 2
1 0263970852

-8051888359E 7'
'TIME
o 2 13

B.9
DHILE
THE FUNCTION HILE PRODUCES A HILBERT MATRiX OF ORDER No

VHILE[OJv
V Z+HILE N
t i : Z++-l+(lN)oo+lN

HILE 3
1 005 003333333333
0 0 5 003333333333 00 25
0 03333333333 00 25 00 2

DINV
THE FUNCTIONS INV AND INVP EACH PRODUCE THE INVERSE OF THE
MATRIX ARGUMENT SUPPLIED, EMPLOYING GAUSS-JORDAN (IoEo,
COMPLETE) ELIMINATION INVP EMPLOYS PIVOTING AND INV DOES
0

NOTo

THE FIRST LINE APPENDS THE UNIT VECTOR l~lN AS THE LAST
COLUMN OF THE ARGUMENT AND THE SECOND LINE (LINE 4 IN INVP)
PERFORMS AT EACH ITERATION ONE OF THE N COMPLETE INVERSIONS
REQUIRED SEE EXERCISE 1
0 OF IVERSON, 4 EHQQR4MMI~Q 040

~4~Q~4Q~, WILEY, 1962 0

VINV[OJV
V Z+INV M;I;J
[lJ M+Q(l 0 +pM)p(,QM),~J+l<lI+ltpM
[2J M+l~(J,l)~[lJM-(JxM[;lJ)ooxM[l;J+M[l;J+M[l;lJ
[3J +2X10~I+I-l
[4J Z+M[;lltpMJ

VINVP[OJv
V Z+INVP M;I;J;K;P
[lJ M+Q(l 0 +pM)p(,QM),~J+l<P+1I+ltpM
[ 2J M[ K, 1 ; 1 P P J +M [ 1 , K+ ( I M[ 1 I ; 1 J ) 1 r/ I M[ 1 I ; 1 J ; 1 PPJ
[3J P+l~P,OpP[K,lJ+P[l,KJ
[4J M+l~(J,l)~[lJM-(JxM[;lJ)ooxM[l;J+M[l;J+M[l;lJ
[5J +2X10~I+I-l
[ 6J Z +M [ ;~PJ

O+N+INV M+HILB 3
9 36 30
36 192 180
30 180 180
M+ xN
o

l o000000000EO 20842170943E-14 6 0039613254E-14


1 0421085472E-14 lo000000000EO lo065814104E-14
40662936703E-15 30197442311E-14 10000000000EO

B.IO
DPALL
THE FUNCTION PALL PRODUCES THE MATRIX OF ALL PERMUTATIONS OF
ORDER No THE FUNCTION PERM WHICH IT USES PRODUCES THE B-TH
PERMUTATION OF ORDER N BY A METHOD DUE TO LoJoWOODRUM o

THE FUNCTION PER EMPLOYS RECURSIVE DEFINITION , AND PRODUCES


ALL PERMUTATIONS BY A METHOD MUCH FASTER THAN THAT USED IN
THE FUNCTION PALL THE PERMUTATIONS ARE PRODUCED IN THE
0

OPPOSI'TE ORDER 0

VPALL[OJ\7
\7 Z+-PALL N;I
[1J Z+-«!N),N)pO
[2J 1+-1
[3J Z[I;J+-N PERM I
[4J +3x(!N)~I+-I+1

VPERM[OJ\7
\7 Z+-A PERM B;I; Y
[1J 1+-pZ+-1+(¢lA)TB-1
[2J +OxIO=I+I-1
[3J Z[YJ+-Z[YJ+Z[IJSZ[Y+-I+IA-IJ
[ 4 J -j-2

VPER[OJ\7
\7 P+-PER M;X;Y;Z
[1J +OxIM=P+ 1 1 p1
[2 J Z+-PER M-1
[3J P+-IX+-O
[4J +OxIM<X+X+1
[5J Y+-(~(lM)EX)\Z
[6J Y[;XJ+-M
[ 7J P+- ( (X x ! M-1 ) , M) p ( , P ) , , Y
[8J +4

PALL 3
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
'TIME
0 3 7
Z+-PALL 3
TIME
0 0 4·9
Z+-PALL 5
'TIME
0 25 10
Z+-PER 5
'TIME
0 1 12
B.ll
DASSOC

THE FUNCTION ASSOC TESTS ANY PUTATIVE GROUP MULTIPLICATION


TABLE M (ASSUMING GROUP ELEMENTS 11ppM) FOR ASSOCIATIVITY
AND YIELDS A VALUE 1 IF IT IS ASSOCIATIVE, 0 OTHERWISE
0

\7ASSOC[O J \7
\7 Z+ASSOC M
[1J Z+~/,M[M;J=Ml;MJ
\7

M+(15)<p5 5P15
M

2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
1 2 3 4 5
TIME
0 0 13
ASSOC M
1
TIME
009
M+O 0 1 0 O<PM
M

2 3 4 5 1
3 4 5 1 2
5 1 2 3 4
5 1 2 3 4
1 2 3 4 5
ASSOC M
0
TIME
0 0 10
M+?10 1 Op 10
pM
10 10
TIME
0 0 3
ASSOC M
0
TIME
0 0 45

B.12
) LOAD 1 NEWS
SAVED 10
044 008 07/12/68

DESCRIBE

THIS WORKSPACE PROVIDES INFORMATION ABOUT THE OPERATION AND


USE OF APL. THE FUNCTIONS OF IN'l'EREST TO THE' USER ARE
APLNOW, INDEX, PRINT, AND SCHEDULE.

APLNOW TAKES AS ITS SINGLE ARGUMENT A THREE-ELEMENT VECTOR


RE/PRESENTING 11 DATE, AS MONTH, DAY, YEAR
0 APLNOW PRINTS
NOTES ON THE STATUS OF THE APL SYSTEM; FOR INSTANCE,
RE'CENTLY ADDED FEATURES, TEMPORARY RESTRICTIONS, OR ADVICE
ON PROGRAMMING OR TERMINAL OPERATION. ONLY THOSE NOTES
ENTERED INTO APLNOW ON OR AFTER THE DATE GIVEN AS AN
ARGUMENT ARE PRINTED o

INDEX TAKES NO ARGUMENT 0I'l' PRINTS INDICES, DATES, AND THE


FIRST FEW WORDS OF EACH NOTE IN APLNOWo

PRINT TAKE'S AS ITS SINGLE' ARGUMENT THE INDEX (AS INDICATED


BY THE INDEX FUNCTION) OF A NOTE FROM APLNOW, AND PRINTS THE
NOTE o

SCHEDULE TAKES NO ARGUMENT. IT INDICATES THE REGULAR DAILY


APL SCHEDULE, AND ALI, AN'TICIPllTED DEVIATIONS FROM THE NORMAL
SCHEDULE.

B.l3
BIBLIOGRAPHY

Berry, P.C., APL\360 Primer, IBM Corporation, 1968.


Berry, P.C., APL\1130 Primer, IBM Corporation, 1968.
Breed, L.M., and R.H. Lathwell, "The Implementation
of APL\360", ACM Symposium on Experimental
Systems for Applied Mathematics, Academic Press,
1968.
Falkoff, A.D., and K.E. Iverson, "The APL\360 Terminal
syat.em" , ACM Symposium on Experimental Systems
for Applied Mathematics, Academic Press, 1968.
Falkoff, A.D., K.E. Iverson, and E.H. Sussenguth, "A
Formal Description of System/360", IBM Systems
Journal, Volume 3, Number 3, 1964.
Iverson, K.E., A Programming Language, Wiley, 1962.

Iverson, K.E., Elementary Functions: an algorithmic


treatment, Science Research Associates, 1966.
Iverson, K.E., "The Role of Computers in Teaching",
Queen's Papers in Pure and Applied Mathematics,
Volume 13, Queen's University, Kingston, Canada,
lq68.

Lathwell, R.H., APL\360: Operator's Manual, IBM


Corporation, 1968.
Lathwell, R.H., APL\360: System Generation and
Library Maintenance, IBM Corporation, 1968.

Pakin, S., APL 360 Reference Manual, Science Research


Associates, 1968.
Rose, A.J., Videotaped APL Course, IBM Corporation,
1968.
Smillie, K.W., Statpack 1: An APL Statistical
Package, Publication No.9, Department of
Computing Science, University of Alberta,
Edmonton, Canada, 1968.
INDEX

Absolute value Comment 3.45


see .Magni tude Communication commands 2.5 2.32-33
Account number 1.8 2.2-3 2.23 action and notes 2.33-35
2.28 table 2.7
Accounting information 1.11 2.10 Comparison 3.8 A.9
ALREADY SIGNED ON 1.9 2.7 Complete beta function 3.9
And 3.5 3.7 3.9 3.34 Compound character 3.3
Announcements, public address 1. 9 Compound expression 3.3 3.14
2.32 Compress 3.38 3.41,-42 A.13
APL Computer
character set 1.3 access 1.1
exercise 4.5-6 failure 2.8
information B.13 time used 1.11 3.47
operations 2.1-3 2.5 Conformabi1ity 3.33 3.36
Application packages 2.13 Connection
Arccos 3.7 broken 1.6 2.4 2.8 2.10
Arccosh 3.7 computer 1.1
Arcsin 3.7 establish 1.4- 6
Arcsinh 3.7 hold 2.11-12
Arctan 3.7 A.2 Constants 3.2
Arctanh 3.7 A.2 CONTINUE 1.11 2.7-9 2.11-12
Arguments 3.5 3.8-9 3.11 3.14-16 Continuity of work 2.22
3.28 3.37 3.41-44 Coordinates of array 3.32 3.35
left 3.8 3.37
right 3.3 COpy 2.7 2.13-14 3.33
Array 3.26-33 A.6-8 action and notes 2 .. 15-18
extend scalar functions to 3.5 Correction 1.7 A.1 A.4
3.33 Cosh 3.7
functions on 2.20 3.33-36 4.3 Cosine 3.7 A.2
A.8-10
Arrow 3.1-5 3.21 3.24
Associativity test B.12
Asterisk 2.30 3.21 Data button 1.6
Attention 1.7 2.4 3.1 3.18 Date 3.47
Date response 2.9-10
Backspace 1. 7 3.3 Deal 3.7 3.38 3.4!5
Base value 3.42 A.13 Decimal form 3.2 4 .. 3
Beta function 3.9 Decode 3.38 3.42 B.2
Binomial coefficient 3.7 A.5 B.5 Defined function 2.3 3.1-16 A.3
Body of defined function 3.10-11 example 3.11 A.3
A.3 explicit argument and result 3.14
Bounce 2.8-9 2.11 3.15
Brackets 3.10 3.17 list names of 2.28
Branch 3.1 3.11 3.20-21 3.45 start and end 3.10
A.3 table of forms 3.1S
e x amp Le 3.12 use 3.16
Business accounting 2.13 variables made local to 3.13
Byte 3.46-47 Definition mode 2.5 3.17
end 3.18 A.3
Caret 3.3 reestablish 3.19
Catenation 3.27 3.29 3.38 4.2 DE'FN ERROR 3.4
Ceiling 3.7-8 A.2 Del 3.10 3.17-19
Cha r a c t.er Del tilde 3.19
error 3.4 Delete 3.17-19
input 3.24-25 DEPTH ERROR 3.4
output 3.26 3.33 Diagonal 3.39 A.11
Characteristic 3.43 DIGITS, output maximum 2.7 2.21
Circle function 3.34 4.7
Circular functions 3.7 Dimension 3.5 3.26-29 3.35
CLEAR 2.7 2.14 3.33 Dimension and rank table 3.27
CLEAR WS 2.6 2.15 Disconnect 1.10 2.8 2.11
Column 3.30-32 3.35 3.42 A.7 Display 3.17-18 A.4
Column catenator 4.2 Divide 3.7 3.34
Colon 2.2-3 2.10 2.14 3.17 DOMAIN ERROR 3.4 3.44 4.3
Combinat,ions B. 7 Drop 3.38 3.44
Comma 3.27-28 DROP 2.7 2.22 2.27
Commands 2.5-7 Dyadic functions 3.7-8 3.34 3.36
table 2.7 Dyadic circle function table 3.7

1.1
e I-beam functions 3.20 3.46-48
see Exponential Identity element table 3.34
Edit IMPROPER LIBRARY REFERENCE 2.7
in function definition 3.18-19 2.26-27 2.31
A.5 INCORRECT COMMAND 2.6-7
text 2.13 INCORRECT SIGN-ON 1.9 2.7
Element-by-element 3.5 3.9 3.33 Index 3.26 3.38
A.l INDEX ERROR 3.4 3.30 3.34
Empty array 3.29 3.33 Index generator 3.9 3.38 A.2
Empty vector 3.10 3.29 A.2 Indexing 3.26 3.30-33 A.14-l5
Encode 3.38 3.43 B.2 Index of 3.38 3.43
Entries 1.6-7 3.2 3.24 Index origin 2.20 3.32-34 A.8
Epsilon Inner product 3.5 3.33 3.35 A.9
see Characteristic table 3.36
Equal 3.7-9 3.34 Input
Equipment 1.1 1.2 character 3.25
Erase 1.7 2.27 3.3 escape from loop 3.25
ERASE 2.7 2.13 2.20 3.19 A.5 evaluated 3.24
Error 1.7 position 1.8 2.4
Error report 3.3 3.5 Input and output 3.23-26 A.6
during defined function 3.5 Inquiry command 1.8 2.5 2.28
table 3.4 action and notes 2.28-32
Evaluated input 3.24 table 2.7
Evaluation, order of Insert by backspacing 3.3
see Order of execution Interrupt 1.1 2.4 2.9 3.20
Exclusive or 3.9 Iota
Execution mode 2.5 3.19 see Index generator, Index of
Execution, order of Iteration counter 3.13
see Order of execution
Expand 3.29 3.38 3.42 A.13
Exponential 3.7 Key 1.8 2.3 2.14
Exponential form 3.2 4.2-3 A.l Keyboard 1.3
Expression, compound 3.3 3.14 locked 1.6-8 2.32-33
unlocked 1.10 2.4 2.34 3.24
Factorial 3.7 3.9 3.16 A.3 Keying time 3.47
Floor 3.7-8
FNS 2.7 2.28 3.22
Function name 2.19 3.2 3.11 Label 3.17
3.23 LABEL ERROR 3.4
Function definition 3.10-11 LENGTH ERROR 3.4 3.33 4.3
3.17-19 A.4-6 Less 3.7 3.9
Functions LIB 2.7 2.31
see Circular, Defined, Dyadic, Library 2.2
Halted, Library, Locked, Mixed, see Private, Public
Monadic, Pendent, Primitive, LIBRARY 1 4.1
Recursive definition, Scalar, ADVANCEDEX B.1-12
Suspended, System dependent APLCOURSE 4.5
Fuzz 3.8 NEWS B.13
TYPEDRILL 4.8-9
Gamma function 3.9 WSFNS 3.32 4.7
Gauss-Jordan elimination B.10 Library control command 2.5
Global object 2.3 2.15-20 3.23 2.22-24
Global variable 2.13-14 2.29 3.13 action and notes 2.25-27
A.3 table 2.7
Grade up and down 3.38 3.44 Library function 2.5 4.1-9
Graph 4.2 4.5 Library number 2.14 2.23
Greater 3.7 3.9 LIBRARY TABLE FULL 2.9
Greatest common divisor A.4 B.5 Line width 2.21
GROUP 2.7 2.13-14 2.19 2.29 List, construct and use B.3
GRP, GRPS 2.7 2.29-30 3.22 LOAD 2.7 2.22
Local variable 2.3 3.13 3.22
Halted function 2.3 2.22 2.30-31 Lock 2.3 2.10
Header 3.13 3.15-19 A.3 Locked function 3.5 3.9
Hexadecimal number B.8 Locked keyboard 1.6-8 2.4 2.32-33
Homonyms 2.3 3.22-23 Logarithm 3.7
Hyperbolic functions Logical function 3.5 3.9
see Circular functions Logical result A.2

1.2
Magni tude 3. 7-· 8 Parentheses in expression 3.3
Material implication 3.9 Parenthesis, right 1.8 2.5-6
Mathema.tical statements 3.1 Password 1.8 2.3 2.10
Matrix 3.26-27 3.33 3.35 A.7 PCOpy 2.13 2.18
A.15 Pendent function 2.3 2.30 3.21
Hilbert B.lO Permutation 3.32 3.37 A.8 A.14
Maximum 3.7 3.34 A.9 B.11
Membership 2.30 3.38 3.43 A.15 Pi times 3.7
Message 1.8 2.21 2.32-33 Plus 3.7 3.34
MESSAGE LOST 2.7 2.33 Polynomial B.6
Minimum 3.7 3.34 Ports 1.1
Minus 3.2 3.7 3.34 PORTS 2.7 2.32
Mixed functions 3.37-45 Power 3.7 3.34
names 3.5 Precision of numbers 2.21 3.5
s ampl,e A.lO-l5 Primitive functions 3.1 3.7 3.14
table 3.38-39 3.38
Monadic functions 3. 7- 8 names 3.5
Monadic transpose 3.40 see Mixed, Scalar
MSG, MSGN 2.7 2.33-34 Printing element 1.1-3
Private library 2.2-3 2.23
Names 2.2-3 2.14 2.19 2.23 Programming examples B.1-12
3.,10 3.13 Protecting copy command 2.13 2.18
acti VE~ and latent referents 3.22 Public library 2.2 2.23 4.1
3.,23
to obt:ain 1ist:s of 2.28-31
Nand 3.7 3.9 3.34 Quad 3.24-25 3.47
Natural logarithm 3.7 Quotation mark 3.2
Negation function 3.2 Quote quad 3.25 3.47
Negative number 3.2 3.7 A.1
NO SPACE 2.9
Nor 3.7 3.9 3.34 Radices 3.42
Not 3.,7 Random 3.7 3.45 A.15
Not equal 3.7-9 3.33 RANK ERROR 3.4 3.33 4.3
Not greater 3.7 3.9 3.34 Rank of array 3.26-27 A.14
NOT GROUPED, NAME IN USE' 2.7 2.19 Ravel 3.27-28 3.38
Not less 3.7 3.9 3.34 Reciprocal 3.7
NOT SA lIED, THIS WS IS wsid 2.7 Recording terminal 1.4 2.8 2.24
2.,27 2.32 2.34-35
NOT SAVED, WS QUOTA USED UP 2.7 Recursive definition 3.16 B.7
2.,27 B.1l
NOT WITH OPEN DEFINITION 2.7 2.16 Reduction 3.5 3.33-35 A.9
2.,25 3.19 Representation 3.43 A.13
NUMBER IN USE 1.9 2.7 Request button on 1050 terminal 1.8
NUMBER LOCKED OUT 1.9 2.7 RESEND 1. 7 3.4
NUMBER NOT IN SYSTEM 1.9 2.7 Reshape 3.28 3.38 A.7
Number of terminals connected 3.47 Residue 3.7-8 3.34
Numbers 3.2 3.5 3.26 Response 1.9-11 2.6 2.10 A.1
table 2.7
OBJECT NOT FOUND 2.7 2.16 Results 3.2 3.14-15
occur-rence s B.4 Return 1.6-7 3.3
OFF 2.7 2.10-11 Reverse 3.38 3.41 A.12
Operator 1.4-5 1.8 Revise 3.17
OPR, OPRN 1.8 2.7 2.34-35 Rho
Or 3.5 3.7 3.9 3.34 see Reshape, Size
Order of execut:ion 3.45 Roll 3. 7
compound exp re s s i.on 3.3 A.1 Rotate 3.38 3.40 A.12
de f i.ried functi.on 3.11 Row 3.30-32 3.35 3.42 A.7
ORIGIN 1.7 2.7 2.20 3.32 4.7
Out of 3.34
Outer product 3.5 3.33 3.35-36 SAVE 2.7 2.22 2.25-26
Output 2.1 2.21 3.23 3.25 Scalar 3 u27 3.37
array 3.33 Scalar functions 3.5-10
fixed point 4.2 extend to arrays 3.33-36
heterogeneous 3.26 sample A.2
maximum digits 2.21 table 3.7
Overstrike 3.3-4 3.19 3.25 Security 2.3
3 .. 35 3.41 3.45 Semicolon 3.13 3.26

1.3
SI, SIV 2.7 2.30-31 3.20-22 Trace 3.16 3.19 3.21 A.3
Sign on 1.8-10 2.7 Transmission signal 1.6-7
Signum 3.7 A.3 Transpose 3.37-41 A.10-ll
Sine 3.7 A.2 Transposition table 3.40
Sine, cosine, tangent table A.ll Trigonometric functions
Sinh 3.7 see Circular functions
Size 3.5 3.27 3.38 Trouble report 1.7 2.6
Spaces 2.6 3.2 table 2.7
Specification 3.1 Typewriter entry 1.6-7 3.2 3.24
multiple 3.45 A.l
State indicator 2.1 2.22 3.20-21
3.48 A.5
with local variables 3.22 User code 1.11 2.28
Statement 3.1
end of 3.3 Value 3.11 3.14-15 3.17 3.25
invalid 3.3 3.5 A.2 3.45
number 3.10-11 3.17-18 3.48 VALUE ERROR 3.4 3.15
Statistical calculations 2.13 Variables
Stop control 3.19 3.21 local and global 2.3 3.13 3.22
Storage 2.1 2.24 3.46 names 2.1-2 2.19 3.22-23
Store workspace 2.25-26 value 3.1 3.14 3.32
Suspended function 2.30 3.20-21 VARS 2.7 2.29 3.22
3.48 Vectors 3.9-10 3.26-27 3.35 A.l
Symbols 3.5 3.7 3.24-25 3.38 mixed functions apply 3.37
3.45 numerical and character constant
SYMBOL TABLE FULL 3.4 3.2 A.l
SYNTAX ERROR 3.4 scalar functions apply 3.9
System command 2.1 2.5-6
during function definition 3.19 WIDTH 2.7 2.21 3.25 4.7
table 2.7 Work session
System dependent function 2.5 2.30 forced end 2.8
3.46-48 to end 1.10-11 2.10-12
table 3.47 to start 1.8
SYSTEM ERROR 3.4 Workspace 1.9 2.1-2
System information 1.9 3.46-48 activate 2.14-15
active 2.13 2.28
Tabular output 4.3 capacity 2.1
Take 3.38 3.44 clear 1.10 2.6 2.14
Tangent 3.7 A.2 continue 1.10 2.8 2.24
Tanh 3.7 identification 2.14 2.23 2.31
Teaching 2.13 identification change 2.22-23
Telephone nQ~ber 1.5 index origin 3.33
Terminal information transfer between 2.13
table of features and options 1.2 in libraries 4.1
1050 1.1 1.5 1.7-8 name 2.2-3
2740 1.4-6 purge an active 2.24
2740-1 1.1 replace stored with active 2.25
2741 1.1 1.4-6 2.4 stored 2.2-3 2.23
Terminal control command 2.5 2.8-9 Workspace control command 2.5
action and notes 2.9-12 2.13-14
table 2.7 action and notes 2.15-22
Terminal, sample session at A.1-15 WS FULL 2.7 2.16 3.4
Terminal modes 2.5 WSID 2.7 2.31
Time 1.9 1.11 2.9 3.46-48 B.7 WS LOCKED 2.7 2.15
Timer on 1050 terminal 1.8 WS NOT FOUND 2.7 2.15 2.27
Times 3.7 3.33
Time, student response 3.47 Zero of a function B.9

1,,4

You might also like