add variable support, implements #10 (#14)

This commit is contained in:
T.v.Dein
2023-11-08 14:47:15 +01:00
committed by GitHub
parent fa5f8dcb3b
commit 31a0ddd547
4 changed files with 88 additions and 5 deletions

14
rpn.go
View File

@@ -164,6 +164,11 @@ DESCRIPTION
help|? show this message
quit|exit|c-d|c-c exit program
Register variables:
>NAME Put last stack element into variable NAME
<NAME Retrieve variable NAME and put onto stack
Refer to https://pkg.go.dev/math for details about those functions.
INTERACTIVE REPL
@@ -205,6 +210,15 @@ COMMENTS
In this case only 123 will be added to the stack.
VARIABLES
You can register the last item of the stack into a variable. Variable
names must be all caps. Use the ">NAME" command to put a value into
variable "NAME". Use "<NAME" to retrieve the value of variable "NAME"
and put it onto the stack.
The command vars can be used to get a list of all variables.
EXTENDING RPN USING LUA
You can use a lua script with lua functions to extend the calculator. By
default the tool looks for "~/.rpn.lua". You can also specify a script