Home, Up: Operators and Constants
This page is intended for advanced users.
WHISK and DONE are called "pseudo operators" because, like operators, they remove arguments to their left, but do not perform any calculations.
On this page:
Pseudo Operator WHISK, Pseudo Operator DONE.
WHISK removes ("whisks away") the two arguments to its left and stores them under the names A and B, which can then be used in the calculation line.
This is useful when a calculation involves the same values more than once (see also the pseudo constant DUP), or to create user-defined 2-argument operators.
(See page User-Defined Operators in chapter "User-Defined Elements".)
A simple example, just to show how WHISK works:
3 4 WHISK A SQ B SQ + SQRT = 5
(Calculating the length of the hypotenuse of a rectangular triangle. A takes the value of 3, B the value of 4. A gets squared, then B gets squared, then the results are added, and the square root is drawn. This example will be used to explain user-defined operators.)
You can use WHISK several times in one calculation line, each time the previous values of A and B will be overwritten.
A and B can only be used following WHISK within a calculation line.
The values of A and B are not preserved after the line has been processed -- this is deliberate.
WHISK deliberately does not auto-include $ at the beginning of the calculation line!
In some cases you may want to "whisk away" only a single value -- you can do this by putting a dummy value (for instance, 0) before WHISK, and then only use A as often in your calculation line where you need it.
WHISK offers a more flexible way of using the same value several times than the pseudo constant DUP.
Where WHISK doesn't solve your problem you have to look at variables, scripts and loops.
DONE preserves the value immediately to its left, and deletes all prior values from the calculation.
Example:
3 4 5 7 + DONE = 12
(The + operator adds 5 and 7 and replaces them with the result 12, then DONE keeps this value but deletes the remaining numbers to the left. Without DONE the calculation would have produced an error due to the remaining surplus arguments.)
While it may seem to make little sense to enter numbers only to delete them, this is for instance needed when generating Fibonacci sequences, and will be discussed in the context of scripts, loops and accumulation mode.
Home, Up: Operators and Constants, Prev: Pseudo Constants, Next Chapter: Numbers