updated docs

This commit is contained in:
2023-11-05 17:39:15 +01:00
parent 11753fc984
commit 2b79f3f9ca
3 changed files with 69 additions and 29 deletions

30
calc.go
View File

@@ -56,22 +56,26 @@ history display calculation history
help|? show this message
quit|exit|c-d|c-c exit program
Available operators:
basic operators: + - x /
Operators:
basic operators: + - x * / ^ (* is an alias of x)
Available math functions:
sqrt square root
mod remainder of division (alias: remainder)
max batch mode only: max of all values
min batch mode only: min of all values
mean batch mode only: mean of all values (alias: avg)
median batch mode only: median of all values
Percent functions:
% percent
%- substract percent
%+ add percent
Math operators:
^ power`
Math functions (see https://pkg.go.dev/math):
mod sqrt abs acos acosh asin asinh atan atan2 atanh cbrt ceil cos cosh
erf erfc erfcinv erfinv exp exp2 expm1 floor gamma ilogb j0 j1 log
log10 log1p log2 logb pow round roundtoeven sin sinh tan tanh trunc y0
y1 copysign dim hypot
Batch functions:
sum sum of all values (alias: +)
max max of all values
min min of all values
mean mean of all values (alias: avg)
median median of all values`
// commands, constants and operators, defined here to feed completion
// and our mode switch in Eval() dynamically
@@ -295,6 +299,10 @@ func (c *Calc) DoFuncall(funcname string) error {
function = c.Funcalls[funcname]
}
if function == nil {
panic("function not defined but in completion list")
}
var args Numbers
batch := false

34
rpn.go
View File

@@ -116,20 +116,36 @@ DESCRIPTION
You can use the shift command to remove the last number from the stack.
BUILTIN OPERATORS AND FUNCTIONS
Basic operators: + - x /
Basic operators:
Math functions:
+ add
- substract
/ divide
x multiply (alias: *)
^ power
Percent functions:
sqrt square root
mod remainder of division (alias: remainder)
max batch mode only: max of all values
min batch mode only: min of all values
mean batch mode only: mean of all values (alias: avg)
median batch mode only: median of all values
% percent
%- substract percent
%+ add percent
^ power
Batch functions:
sum sum of all values (alias: +)
max max of all values
min min of all values
mean mean of all values (alias: avg)
median median of all values
Math functions:
mod sqrt abs acos acosh asin asinh atan atan2 atanh cbrt ceil cos cosh
erf erfc erfcinv erfinv exp exp2 expm1 floor gamma ilogb j0 j1 log
log10 log1p log2 logb pow round roundtoeven sin sinh tan tanh trunc y0
y1 copysign dim hypot
Refer to https://pkg.go.dev/math for details about those functions.
EXTENDING RPN USING LUA
You can use a lua script with lua functions to extend the calculator. By

34
rpn.pod
View File

@@ -123,20 +123,36 @@ stack.
=head2 BUILTIN OPERATORS AND FUNCTIONS
Basic operators: + - x /
Basic operators:
Math functions:
+ add
- substract
/ divide
x multiply (alias: *)
^ power
Percent functions:
sqrt square root
mod remainder of division (alias: remainder)
max batch mode only: max of all values
min batch mode only: min of all values
mean batch mode only: mean of all values (alias: avg)
median batch mode only: median of all values
% percent
%- substract percent
%+ add percent
^ power
Batch functions:
sum sum of all values (alias: +)
max max of all values
min min of all values
mean mean of all values (alias: avg)
median median of all values
Math functions:
mod sqrt abs acos acosh asin asinh atan atan2 atanh cbrt ceil cos cosh
erf erfc erfcinv erfinv exp exp2 expm1 floor gamma ilogb j0 j1 log
log10 log1p log2 logb pow round roundtoeven sin sinh tan tanh trunc y0
y1 copysign dim hypot
Refer to https://pkg.go.dev/math for details about those functions.
=head1 EXTENDING RPN USING LUA