|
Gri Commands
|
12.40: The `
|
`rpnfunction name replacement-words' |
Create a new keyword for use in rpn expressions. Inside any RPN
expression which follows this line, the word `name' will be
substituted with the indicated replacement words.
For example,
the following shows the definition and use of a function which computes
the sine of twice an angle, by multiplying whatever is on the stack by
`2', and then taking the sine of the result.
rpnfunction sin2 2 * sin
show "expect the number 1 to follow: " {rpn 45 sin2}
|
The replacement words will have any synonyms in them translated first,
unless they start with an underscore followed by a double backslash.
Similarly, variables are substituted unless they start with an
underscore. These exceptions are to allow the use of the `defined'
operator; see rpn Mathematics.
Note: The mathematical constants `e' and `pi' are stored using
`rpnfunctions'. Also, two `rpnfunctions' are provided for
finding the slope and intercept of a line joining two points, e.g.
# Expect answers 1 and 10 ...
show "slope=" {rpn 0 1 1 11 linear_slope}
show "inter=" {rpn 0 1 1 11 linear_intercept}
|
set grid missing above .intercept. .slope.'
and `set z missing above .intercept. .slope.'.