You can also separate the input data with spaces in a single stack line rather
than using `.
Programs that simulate a sequence of stack operations
In this case, the terms to be involved in the sequence of operations are
assumed to be present in the stack. The program is typed in by first opening
the program containers with ‚å. Next, the sequence of operations to
be performed is entered. When all the operations have been typed in, press
` to complete the program. If this is to be a once-only program, you can
at this point, press µ to execute the program using the input data available.
If it is to be a permanent program, it needs to be stored in a variable name.
The best way to describe this type of programs is with an example:
Example: Velocity head for a rectangular channel.
Suppose that we want to calculate the velocity head, h
, in a rectangular
channel of width b, with a flow depth y, that carries a discharge Q. The
specific energy is calculated as h
), where g is the acceleration
of gravity (g = 9.806 m/s
in S.I. units or g = 32.2 ft/s
in E.S. units). If we
were to calculate h
for Q = 23 cfs (cubic feet per second = ft
/s), b = 3 ft,
and y = 2 ft, we would use: h
). Using the RPN
modethe calculator, interactively, we can calculate this quantity as:
Resulting in 0.228174, or h
To put this calculation together as a program we need to have the input data
(Q, g, b, y) in the stack in the order in which they will be used in the
calculation. In terms of the variables Q, g, b, and y, the calculation just
performed is written as (do not type the following):
y ` b *„º g *2* Q „º™/