Page 21-26
Store the new program back into variable
@@@p@@@
. Press
@@@p@@@
to run the program.
Enter values of V = 0.01_m^3 and T = 300_K in the input string, then press
`
. The result is 49887.06_J/m^3. The units of J/m^3 are equivalent to
Pascals (Pa), the preferred pressure unit in the S.I. system.
Note
: because we deliberately included units in the function definition, the
input values must have units attach to them in input to produce the proper
result.
Input string program for three input values
The input string program for three input values, say a ,b, and c, looks as
follows:
«
“
Enter a, b and c:
“
{
“
:a:
:b:
:c:
“
{2 0} V }
INPUT OBJ
→
»
This program can be easily created by modifying the contents of INPT2 to
make it look like shown immediately above. The resulting program can then
be stored in a variable called INPT3. With this program we complete the
collection of input string programs that will allow us to enter one, two, or three
data values. Keep these programs as a reference and copy and modify them
to fulfill the requirements of new programs you write.
Application
:
evaluating a function of three variables
Suppose that we want to program the ideal gas law including the number of
moles, n, as an additional variable, i.e., we want to define the function
,
)
_
31451
.
8
(
)
,
,
(
V
T
n
K
J
n
T
V
p
⋅
=
and modify it to include the three-variable input string. The procedure to put
together this function is very similar to that used earlier in defining the function
p(V,T). The resulting program will look like this:
«
“
Enter V, T, and n:
“
{
“
:V:
:T:
:n:
“
{2 0} V }
INPUT OBJ
→
→
V T n
‘
(8.31451_J/(K*mol))*(n*T/V)
‘
»
Store this result back into the variable
@@@p@@@
.To run the program, press
@@@p@@@
.