Previous: Overview Up: Writing Programs in CL for Maxima

Interfacing to MAXIMA

The MAXIMA top level is a read-eval-print loop much like that of lisp. It

  1. Read the next command typed by the user.
  2. Parse the command and render it into an internal form.
  3. This internal form is evaluated by the function "meval", the maxima evaluator. The "meval" execution produces a result which in valid maxima internal representation.
  4. The result is simplified by the function "simplifya" which transforms the answer and returns a valid internal representation.
  5. The final answer is displayed in 2-D form by "displa".
  6. The prompt for the next C-line is displayed and the cycles restarts from step 1.

As part of step 2, MAXIMA puts a $ prefix to each and every variable and function name in the command line. Therefore, a name at maxima top level is equated with the same lisp level name with a $ prefix. This also means that if you use a global lisp variable that has a $ prefix, you are dealing with a quantity accessible at maxima top level by that same name without the $ sign.

Arrange your CL package to have a main function and give it a name with a leading $ sign, e.g. $quadsolve. This means you are building the support for a maxima top level command quadsolve. If function will receive input arguments and produce the desired result. The incoming arguments will be in simplified maxima internal representation. The result produced by the $quadsolve function can be a yet unsimplified expression in valid internal form. Control passes into your main function $quadsolve from maxima via step 3. The result $quadsolve returns will then be treated by steps 4 and 5. Thus, your code is correctly interfaced to Maxima.

A lisp file is loaded into maxima by using the maxima loadfile command. For example


loadfile("quadsolve.lsp")$

farrell@mcs.kent.edu