MNX program listing
|
| Program: | Comments: |
|
|
|
|
|
| « |
|
|
| {{ "MAX" | Defines the option menu. %MAX% sets |
|
| « 10 SF CONT » } | flag 10 and continues execution. |
|
| { "MIN" | %MIN% clears flag 10 and continues |
|
| « 10 CF CONT » }} | execution. |
|
|
| |
|
| TMENU | Displays the temporary menu and a |
|
| "Sort for MAX or MIN?" | prompt message. |
|
| PROMPT |
|
|
| 1 GETI | Gets the first element of the array. |
|
| DO | Begins the DO loop. |
|
| ROT ROT GETI | Puts the index and the array in levels |
|
|
| 1 and 2, then gets the new array |
|
|
| element. |
|
| 4 ROLL DUP2 | Moves the current minimum or |
|
|
| maximum array element from level 4 |
|
|
| below 1, then copies both. |
|
| IF | Tests the combined state of the |
|
| > 10 FS? XOR | relative value of the two elements and |
|
|
| the status of flag 10. |
|
| THEN | If the new element is either less than |
|
| SWAP | the current maximum or greater than |
|
| END | the current minimum, swaps the new |
|
|
| element into level 1. |
|
| DROP | Drops the other element off the |
|
|
| stack. |
|
| UNTIL | Begins the DO |
|
| Tests if flag | |
|
|
| reached the end of the array. |
|
| END | Ends the DO loop. |
|
| SWAP DROP 0 MENU | 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:
1256
451
9 14
RPL Programming Examples