Variable: calculator-user-operators

calculator-user-operators is a customizable variable defined in calculator.el.gz.

Value

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 simple: use X for the argument (Y
  for a second one 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 operator:

  (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.

Source Code

;; Defined in /usr/src/emacs/lisp/calculator.el.gz
(defcustom calculator-user-operators nil
  "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 simple: use `X' for the argument (`Y'
  for a second one 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 operator:

  (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'."
  :type  '(repeat (list string symbol sexp integer integer)))