Skip to content

Commit

Permalink
Doc/improve (#4)
Browse files Browse the repository at this point in the history
* add interactiveness to features, add keybindings to doc
* added commands
  • Loading branch information
TLINDEN authored Nov 6, 2023
1 parent bb49cb7 commit ad2d9d9
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ Features:
- various stack manipulation commands
- basic math operators
- advanced math functions (not yet complete)
- provides interactive repl
- can be used on the commandline
- can calculate data in batch mode (also from STDIN)
- extensible with custom LUA functions
- provides interactive repl
- completion
- history


## Working principle

Expand Down
48 changes: 47 additions & 1 deletion rpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ DESCRIPTION
switch or debug toggle command), then the backup stack is also being
displayed.
The stack can be reversed using the reverse command.
The stack can be reversed using the reverse command. However, sometimes
only the last two values are in the wrong order. Use the swap command to
exchange them.
You can use the shift command to remove the last number from the stack.
Expand Down Expand Up @@ -145,8 +147,52 @@ DESCRIPTION
log10 log1p log2 logb pow round roundtoeven sin sinh tan tanh trunc y0
y1 copysign dim hypot
Commands:
batch toggle batch mode
debug toggle debug output
dump display the stack contents
clear clear the whole stack
shift remove the last element of the stack
reverse reverse the stack elements
swap exchange the last two stack elements
show show the last 5 items of the stack
history display calculation history
help|? show this message
quit|exit|c-d|c-c exit program
Refer to https://pkg.go.dev/math for details about those functions.
INTERACTIVE REPL
While you can use rpn in the command-line, the best experience you'll
have is the interactive repl (read eval print loop). Just execute "rpn"
and you'll be there.
In interactive mode you can use TAB completion to complete commands,
operators and functions. There's also a history, which allows you to
repeat complicated calculations (as long as you've entered them in one
line).
There are also a lot of key bindings, here are the most important ones:
ctrl-c + ctrl-d
Exit interactive rpn
ctrl-z
Send rpn to the backgound.
ctrl-a
Beginning of line.
ctrl-e
End of line.
ctrl-l
Clear the screen.
ctrl-r
Search through history.
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
Expand Down
57 changes: 57 additions & 0 deletions rpn.pod
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,65 @@ Math functions:
log10 log1p log2 logb pow round roundtoeven sin sinh tan tanh trunc y0
y1 copysign dim hypot

Commands:

batch toggle batch mode
debug toggle debug output
dump display the stack contents
clear clear the whole stack
shift remove the last element of the stack
reverse reverse the stack elements
swap exchange the last two stack elements
show show the last 5 items of the stack
history display calculation history
help|? show this message
quit|exit|c-d|c-c exit program


Refer to https://pkg.go.dev/math for details about those functions.

=head1 INTERACTIVE REPL

While you can use rpn in the command-line, the best experience you'll
have is the interactive repl (read eval print loop). Just execute
C<rpn> and you'll be there.

In interactive mode you can use TAB completion to complete commands,
operators and functions. There's also a history, which allows you to
repeat complicated calculations (as long as you've entered them in one
line).

There are also a lot of key bindings, here are the most important
ones:

=over

=item ctrl-c + ctrl-d

Exit interactive rpn

=item ctrl-z

Send rpn to the backgound.

=item ctrl-a

Beginning of line.

=item ctrl-e

End of line.

=item ctrl-l

Clear the screen.

=item ctrl-r

Search through history.

=back

=head1 EXTENDING RPN USING LUA

You can use a lua script with lua functions to extend the
Expand Down

0 comments on commit ad2d9d9

Please sign in to comment.