RPL Programming Examples 2-17
MNX program listing
Program: Comments:
"!
ff!IMBTI!
"!38!D7!OL=:!1!h!
f!IM6=I!
"!38!O7!OL=:!1!hh!
Defines the option menu. %MAX% sets
flag 10 and continues execution. %MIN%
clears flag 10 and continues execution.
:M<=5!
IDkjp!*kj!MBT!kj!M6=bI
2KLM2:!
Displays the temporary menu and a
prompt message.
3!><:6!
4L!
KL:!KL:!><:6!
Gets the first element of the array.
Begins the DO loop.
Puts the index and the array in levels 1
and 2, then gets the new array element.
a!KLEE!452H!
Moves the current minimum or
maximum array element from level 4
below 1, then copies both.
67!
9!38!7Db!TLK!
Tests the combined state of the relative
value of the two elements and the status
of flag 10.
:;<=!
DYB2!
<=4!
If the new element is either less than
the current maximum or greater than
the current minimum, swaps the new
element into level 1.
4KL2!
Drops the other element off the stack.
5=:6E!
0ca!7Db!
Begins the DO test-clause.
Tests if flag
–64 is set — if the index
reached the end of the array.
<=4!
DYB2!4KL2!8!M<=5!
Ends the DO loop.
Swaps the index to level 1 and drops it.
Restores the last menu.
»
`OMNX K
Stores the program in MNX.
Checksum: # 20991d
Bytes: 194.5
Example: Find the maximum element of the following matrix:
12 56
45 1
914
Enter the matrix.