2-22 RPL Programming Examples
Program: Comments:
!!!!!!!+o.-G0t/'t+!<NBE
!!!!!!!KLEE4!
Computes the number of elements to roll so that the
next row can be collected.
!!!!!!=<T:!
!!!!!!G!#E6D:!
Repeat loop for the next row. Gather rows into a list,
forming a list of lists (symbolic pseudo-array).
!!!!!1!
!!!<=4!3!O7!
Close the local variable structure and end the
IFERR…THEN...END structure. Clear flag 1 before
exiting the program.
!!1!
1!
`OAPLY K
Stores the program in APLY.
Checksum: # 11132d
Bytes: 314
Example: Apply the function, f(x) = Ax
3
-7 to each element x of the vector [ 3 -2 4 ].
!Ô3†2W†4`
‚å 3 QA *7 -
`J %APLY%
H#DISP ˜˜
(select small stack display to see
all vector elements.)
Converting Between Number Bases
nBASE converts a positive decimal number (x) into a tagged string representation of the equivalent value in a
different number base (b). Both x and b must be real numbers. nBASE automatically rounds both arguments to
the nearest integer.
Level 2 Level 1 " Level 1
x b
"
x baseb: "string"
Techniques used in nBASE
! String Concatenation and Character Manipulation. nBASE makes use of several string and character
manipulation techniques to build up the result string.
! Tagged Output. nBASE labels (“tags”) the output string with its original arguments so that the output is a
complete record of the command.
! Indefinite Loops. nBASE accomplishes most of its work using indefinite loops — both DO...UNTIL...END
and WHILE...REPEAT...END loops.