Process; Putting It All Together - IBM 5110 User Manual

Apl
Table of Contents

Advertisement

8
Process
Your introduction to APL started with APL's processing ability. The
APL language is designed to do processing with a minimum number of
instructions.
Once the input and output are well defined, all of the characteristics
work together to make the process part the most straightforward.
For our compound interest example, the process part consists of:
1.
Defining the algorithm used to calculate the compound interest
2.
Using the input to generate the results
The formula used in this example for the compound interest is:
CI
=
Principal x (1 + .01 x Interest Rate}Y6arS
The APL statements that use the input to generate the results might
be as follows:
A~l+,Ol~INTERESTRATE
B~"A*
YEA
I~S
C~"PRINCI
PAL)(B
PUTTING IT ALL TOGETHER
Now that you have considered the three parts of the application, it is
time to write your user-defined function. For the compound interest
example, your user-defined function might look like this:
[:I.]
[2]
[:3]
['+]
V
R~"
P
I~
I
NC
I
PAL
COt-l POUND
YEt~ I~f
Th~
interest
r~te m~st
be
A~":I.+O
():I.)(
INTEI~ESTI~ATE ~asslgned
to
~hls
vanabl.e
b~fore
IH"A')('YEr.t1~S
the user-defmed function
IS
C
I~"
P
I~
I NC I P
t-d ... )(
B
executed.
R~"
I
THE IN T E
I~
EST E A
I~
N E
[I
IS:
I
I
:1. ()
2
'f'
C I
v
So far, you have taken a simple application and designed a
user-defined function to solve it. If the application is larger or more
complex, a more detailed structure is required. This more detailed
structure involves expanding each of the three parts (input, process,
and output) into additional levels of input, process, and output.

Advertisement

Table of Contents
loading

Table of Contents