• Aucun résultat trouvé

APL Introduction

Dans le document APL/PC Version 2.1 (Page 22-31)

Chapter 1. Introduction ••...•...•...•.•..••• 1-1 The APL Package . . . 1-8 The APL Character ROM . . . 1-8 Displaying APL Characters using the Enhanced

Graphics Adapter . . . 1-12 Displaying APL Characters using the Professional

Graphics Adapter . . . 1-12 Backing U p Your Diskettes . . . 1-13 Installing APL on Your Fixed Disk . . . 1-13 Getting APL Started from Either Diskette or Fixed

Disk . . . 1-15 Including Options in the APL Command . . . 1-16 The APL Character Set . . . 1-18 The Keyboard . . . 1-19 Function Keys . . . 1-19 Typewriter Keyboard . . . 1-21 Numeric Keypad . . . 1-24 Special Key Combinations . . . 1-25 Keyboard Keycaps . . . 1-26 Keyboard Template . . . 1-27 The APL Input Editor . . . 1-29 APL Input Editor Special Keys . . . 1-29 How to Make Corrections on the Current Line 1-32 Use of Displays . . . 1-33 Disk(ette) Drives . . . 1-35 The Printer . . . 1-36 Chapter 2. APL Tutorial ....•...•.•.•..•. 2-1 What is APL? . . . 2-3 Arrays and Functions . . . 2-4 Interactivity . . . 2-7 The APL Calculator . . . 2-8 Order of Execution . . . 2-10 Powers and Logarithms . . . : . . . 2-11 Circular Functions . . . 2-13 Computations with Multiple Data Items ... 2-14

Part 1. APL Introduction

IBM Internal Use Onl~

Variations on the Compound Interest Problem .. 2-17 Named Data . . . 2-18 APL Workspaces . . . 2-20 Other Functions and Operators . . . 2-24 Input/Output . . . 2-24 Shared Variables . . . 2-25 A Simple Example . . . 2-26 Shared and Other Variables . . . 2-27 Debugging . . . 2-28 Quad output . . . 2-29 Tracing . . . 2-30 Stopping . . . 2-31 Alternate execution . . . '. . . . . . . . .. 2-31 Speeding Up APL Code . . . 2-32 Use Timing Tools to Find Hot Spots . . . 2-33 Eliminate Explicit Loops . . . 2-33 Avoid Waxing or Waning Variables . . . 2-35 A void Large Outer Products . . . 2-36 Avoid Tiny Functions . . . 2-36 An Example - Computing a Histogram . . . 2-37 Computing the Histogram with an Explicit Loop 2-37 Computing the I-Iistogram with an Outer Product 2-39 Computing the Histogram with Grade Up ... 2-41 How to Write a Timing Function . . . 2-42

A Simple Timing Program . . . 2-42 An Improved Timing Function . . . 2-44 An Alternative Solution . . . 2-46 Concluding Thought . . . 2-47 Further Reading . . . 2-48

APLjPC, Version 2.1

[BM Internal Use Only

Chapter 1. Introduction

The APL Package . . . 1-8 The APL Character ROM . . . 1-8 Displaying APL Characters using the Enhanced

Graphics Adapter . . . 1-12 Displaying APL Characters using the Professional

Graphics Adapter . . . 1-12 Backing Up Y o·ur Diskettes . . . 1-13 Installing APL on Your Fixed Disk . . . 1-13 Getting APL Started from Either Diskette or Fixed

Disk . . . 1-15 Including Options in the APL Command . . . 1-16 The APL Character Set . . . 1-18 The Keyboard . . . 1-19 Function Keys . . . 1-19 Typewriter Keyboard . . . 1-21 Numeric Keypad . . . 1-24 Special Key Combinations . . . 1-25 Keyboard Keycaps . . . 1-26 Keyboard Template . . . 1-27 The APL Input Editor . . . 1-29 APL Input Editor Special Keys . . . 1-29 How to Make Corrections on the Current Line 1-32 Use of Displays . . . 1-33 Disk(ette) Drives . . . 1-35 The Printer . . . 1-36

Chapter 1. Introduction 1-1

IBM Internal Use Only

Notes:

1-2 APL/PC, Version 2.1

IBM Internal Use Only

APL is a general-purpose language that enjoys wide use in such diverse applications as commercial data processing, system design, mathematical and scientific computation, and the teaching of mathematics and other subjects. It has proved particularly useful in data-base applications, where its

computational power and communication facilities combine to increase the productivity of both application programmers and end users.

When implemented as a computing system, APL is used from a typewriter-like keyboard. Statements that specify the work to be done are typed and the computer responds by displaying the result of the work at a device such as a video display or printer. In addition to work purely at the keyboard and its associated display, entries may also specify the use of printers, disk files, or other remote devices.

A programming language should be relevant. That is, you should have to write only what is logically necessary to specify the job you want done. This may seem an obvious point, but many of the earlier programming languages forced you to be concerned as much with the internal requirements of the machine as with your own statement of the problem. APL takes care of those internal considerations automatically.

A programming language needs both both power and simplicity. By power, we mean the ability to handle large or conlplicated tasks. By simplicity, we mean the ability to state what must be done briefly and neatly, in a way that is easy to read and easy to write. You might think that power and simplicity are competing requirements, so that if you have one, you can't have the other, but that is not necessarily so.

Simplicity does not mean the computer is limited to doing simple tasks, but that the user has a simple way to write instructions to the computer. The power of APL as a programming language comes in part from its simplicity.

The letters, APL, originated with the initials of a book written by K. E. Iverson, A Programming Language (New York:

Wiley, 1962). Dr. Iverson first worked on the language at I-Iarvard University, and then continued its development at IBM with the collaboration of Adin Falkoff and others at the IBM T.]. Watson Research Centre. The term APL now refers

Chapter 1. Introduction 1-3

IBM Internal Use Only

to the language that is an outgrowth of that work. AP L is the language, and IBM Personal Computer APL is the

"brand-name" of a particular implementation of that language, with extensions. The implementation and extensions were developed by the IBM Madrid Scientific Centre. This implementation, hereafter called APL, has the following features:

• Shared variables, which allow the exchange of information between independently operating processors. This allows the separate loading of only those auxiliary processors needed for a particular work session or application. It also makes possible the design of new auxiliary processors for an application that may not be currently supported by the system.

• Facilities for conversion between the internal form and transfer form of APL objects, including )IN, lOUT and OTF, that allow workspaces to be interchanged between different systems.

• Asynchronous communications with the IBM Virtual Machine Facility/370 permits the exchange of works paces and data files between systems, and allows devices attached to the host to be used.

• All dyadic-defined functions are ambivalent, which allows them to be used monadically without generating a syntax error. The system function, ONe, can be applied to the left argument" within a function to determine, at execution time, whether the function actually has been called as dyadic or monadic.

• Improved error recovery is made possible by the )RESET command, which clears the state indicator, and DEA (execute alternate), which allows the trapping of an APL interrupt and error message to permit programmed means of recovery.

• Event handling facilities are provided through an APL interface to the BIOS/DOS interrupts, thus allowing these

1-4 APL/PC, Version 2.1

[BM Internal Use Only

interrupts to be trapped or generated for more control of the system environment.

• The APL Workspace consists of two parts:

The main workspace, which has a maximum size of 64K bytes, where all APL statements are executed and small APL objects are created and modified.

The elastic workspace, which can use all additional free memory. If space is needed for an operation in the main workspace, every obj~ct not currently being referenced will be automatically relocated to the elastic workspace, and returned as needed.

• The following four data types are supported, and the system automatically performs data-type conversions whenever possible to minimise storage space:

Floating-point, with eight bytes per element Integer, with two bytes per element

Character, with one byte per element Boolean, with one bit per element

• The IBM Personal Computer Math Co-Processor may be used for improved performance of floating-point

operations, such as the APL transcendental functions.

• The ability to start an application automatically by specifying an APL system command at load time before starting a work session. Functions that imitate some of the system commands also are provided allowing the system environment to be controlled from within a defined function.

• The execution of machine code subroutines and the PEEK and POKE memory contents is provided through the DPK system function.

Chapter 1. Introduction 1-5

IBM Internal Use Only

• The appearance of numeric output can be improved using picture format, and the dyadic grades allow character data to be sorted in a specified collating sequence.

• Dynamic switching (either from the keyboard or by

software control) between the APL and National character sets on the keyboard provides access to an extensive set of characters that can be entered with one keystroke. The keyboard layout may also be redefined dynamically to allow for the various keyboard arrangements used on European keyboards.

• Multiple display monitors can be used, with dynamic switching between all modes.

• A full-screen input and output capability provides a full-screen input editor, which allows corrections to be made to a previous line that can then be re-entered for execution. A full-screen, defined-function editor, and multiple line deletion under the del (V) editor, increase the ease with which programs can be created and edited.

• A file management capability allows the control of either APL or DOS files, with sequential or direct access of fixed length and variable length records.

• The optional IBM Graphics Printer can produce APL characters, and can be used either as a system log to provide a record of a work session, or to selectively print a desired APL object or result.

• The speaker attached to the system unit of the IBM personal computer can be used to generate music.

To use the IBM Personal Computer APL system, you must have the following minimum configuration:

• Either: the IBM Personal Computer, the IBM Portable Personal Computer, the IBM Personal Computer XT, the IBM Personal Computer AT, the IBM 5140 PC

Convertible, the IBM 3270 Personal Computer/G, or the IBM 3270 Personal Computer/GX.

1-6 APL/PC, Version 2.1

IBM Internal Use Only

The IBM 3270 Personal Computer may be used, but this requires the "All Points Addressable Adapter card" in order to be able to display the APL character set correctly.

The IBM 4860 PCjr must be modified with a small hardware change. This is given in

Appendix G, "Hardware Modification for IBM 4860 PCjr" .

• 192K or more of random access memory. A minimum of 256K is preferred.

• One double-sided 5.25 inch diskette drive

• The IBM Monochrome and Printer Adapter, the IBM Colour Graphics Adapter (or any hardware that emulates it), the IBM Enhanced Graphics Adapter, or the IBM Professional Graphics Adapter.

• DOS 2.0, or later version.

• Either: the IBM Monochrome Display, the IBM Colour Display, the IBM Enhanced Colour Display, the IBM Professional Colour Display, any other monitors that attach to an appropriate adapter, or a television set and RF modulator. (Television sets and RF modulators are not sold by IBM).

• Optional IBM Personal Computer Math Co-Processor

• Optional IBM 80 CPS Graphics Printer or the IBM Proprinter, with either the Parallel Printer Adapter or the Monochrome Display and Printer Adapter.

• Optional IBM Personal Computer Expansion Unit

• Optional IBM Asynchronous Communications Adapter

Chapter 1. Introduction 1-7

IBI\1 Internal Use Only

Dans le document APL/PC Version 2.1 (Page 22-31)

Documents relatifs