Gri Commands

1: Introduction
2: Simple example
3: Fancy example
4: Running Gri
5: Programming Gri
6: General Issues
7: X-Y Plots
8: Contour Plots
9: Image Plots
10: Examples
11: Handling Data
12: Gri Commands
13: Gri Extras
14: Evolution of Gri
15: Installing Gri
16: Gri Bugs
17: System Tools
18: Acknowledgments
19: License
20: Newsgroup

21: Concept Index

12.40: The `rpnfunction' Command

`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}
These are useful in `set grid missing above .intercept. .slope.' and `set z missing above .intercept. .slope.'.