calc: Programming

 
 18 Programming
 **************
 
 There are several ways to “program” the Emacs Calculator, depending on
 the nature of the problem you need to solve.
 
   1. “Keyboard macros” allow you to record a sequence of keystrokes and
      play them back at a later time.  This is just the standard Emacs
      keyboard macro mechanism, dressed up with a few more features such
      as loops and conditionals.
 
   2. “Algebraic definitions” allow you to use any formula to define a
      new function.  This function can then be used in algebraic formulas
      or as an interactive command.
 
   3. “Rewrite rules” are discussed in the section on algebra commands.
      SeeRewrite Rules.  If you put your rewrite rules in the
      variable ‘EvalRules’, they will be applied automatically to all
      Calc results in just the same way as an internal “rule” is applied
      to evaluate ‘sqrt(9)’ to 3 and so on.  SeeAutomatic Rewrites.
 
   4. “Lisp” is the programming language that Calc (and most of Emacs) is
      written in.  If the above techniques aren’t powerful enough, you
      can write Lisp functions to do anything that built-in Calc commands
      can do.  Lisp code is also somewhat faster than keyboard macros or
      rewrite rules.
 
    Programming features are available through the ‘z’ and ‘Z’ prefix
 keys.  New commands that you define are two-key sequences beginning with
 ‘z’.  Commands for managing these definitions use the shift-‘Z’ prefix.
 (The ‘Z T’ (‘calc-timing’) command is described elsewhere; See
 Troubleshooting Commands.  The ‘Z C’ (‘calc-user-define-composition’)
 command is also described elsewhere; SeeUser-Defined Compositions.)
 

Menu