calculator-user-operators
calculator-user-operators is a variable defined in `
calculator.el
'.
Its value is
nil
Documentation:
A list of additional operators.
This is a list in the same format as specified in the documentation for
`calculator-operators', that you can use to bind additional calculator
operators. It is probably not a good idea to modify this value with
`customize' since it is too complex...
Examples:
* A very simple one, adding a postfix "x-to-y" conversion keys, using
t as a prefix key:
(setq calculator-user-operators
'(("tf" cl-to-fr (+ 32 (/ (* X 9) 5)) 1)
("tc" fr-to-cl (/ (* (- X 32) 5) 9) 1)
("tp" kg-to-lb (/ X 0.453592) 1)
("tk" lb-to-kg (* X 0.453592) 1)
("tF" mt-to-ft (/ X 0.3048) 1)
("tM" ft-to-mt (* X 0.3048) 1)))
* Using a function-like form is very simple: use `X' for the argument
(`Y' for the second in case of a binary operator), `TX' is a truncated
version of `X' and `F' for a recursive call. Here is a [very
inefficient] Fibonacci number calculation:
(add-to-list 'calculator-user-operators
'("F" fib
(if (<= TX 1) 1 (+ (F (- TX 1)) (F (- TX 2))))))
Note that this will be either postfix or prefix, according to
`calculator-unary-style'.
You can customize this variable.