The functions described here are responsible for parsing and formatting Calc numbers and formulas.
This is the simplest interface to the Calculator from another Lisp program. See Calling Calc from Your Programs.
If string str contains a valid Calc number, either integer, fraction, float, or HMS form, this function parses and returns that number. Otherwise, it returns
Read an algebraic expression from string str. If str does not have the form of a valid expression, return a list of the form ‘(error pos msg)’ where pos is an integer index into str of the general location of the error, and msg is a string describing the problem.
Read a list of expressions separated by commas, and return it as a Lisp list. If an error occurs in any expressions, an error list as shown above is returned instead.
Read an algebraic formula or formulas using the minibuffer. All conventions of regular algebraic entry are observed. The return value is a list of Calc formulas; there will be more than one if the user entered a list of values separated by commas. The result is
nilif the user presses Return with a blank line. If initial is given, it is a string which the minibuffer will initially contain. If prompt is given, it is the prompt string to use; the default is “Algebraic:”. If no-norm is
t, the formulas will be returned exactly as parsed; otherwise, they will be passed through
To support the use of $ characters in the algebraic entry, use
calc-dollar-valuesto a list of the values to be substituted for $, $$, and so on, and bind
calc-dollar-usedto 0. Upon return,
calc-dollar-usedwill have been changed to the highest number of consecutive $s that actually appeared in the input.
Convert the arbitrary Calc number or formula a to string form, in the style used by the trail buffer and the
calc-editcommand. This is a simple format designed mostly to guarantee the string is of a form that can be re-parsed by
read-expr. Most formatting modes, such as digit grouping, complex number format, and point character, are ignored to ensure the result will be re-readable. The prec parameter is normally 0; if you pass a large integer like 1000 instead, the expression will be surrounded by parentheses unless it is a plain number or variable name.
This is like
format-flat-expr(with prec equal to 0), except that newlines will be inserted to keep lines down to the specified width, and vectors that look like matrices or rewrite rules are written in a pseudo-matrix format. The
calc-editcommand uses this when only one stack entry is being edited.
Convert the Calc number or formula a to string form, using the format seen in the stack buffer. Beware the string returned may not be re-readable by
read-expr, for example, because of digit grouping. Multi-line objects like matrices produce strings that contain newline characters to separate the lines. The w parameter, if given, is the target window size for which to format the expressions. If w is omitted, the width of the Calculator window is used.
Format the Calc number or formula a according to the current language mode, returning a “composition.” To learn about the structure of compositions, see the comments in the Calc source code. You can specify the format of a given type of function call by putting a
math-compose-lang property on the function's symbol, whose value is a Lisp function that takes a and prec as arguments and returns a composition. Here lang is a language mode name, one of
maple. In Big mode, Calc actually tries
math-compose-bigfirst, then tries
math-compose-normal. If this property does not exist, or if the function returns
nil, the function is written in the normal function-call notation for that language.
Convert a composition structure returned by
compose-exprinto a string. Multi-line compositions convert to strings containing newline characters. The target window size is given by w. The
format-valuefunction basically calls
Compute the portion of the height of composition c which is on or above the baseline. For a one-line composition, this will be one.
Compute the portion of the height of composition c which is below the baseline. For a one-line composition, this will be zero.
If composition c is a “flat” composition, return the first (leftmost) character of the composition as an integer. Otherwise, return