List of Parasolid LISP Functions
<<< Error Codes in Parasolid LISP | Chapters | KID Examples >>> |
This is the current list of PARASOLID LISP functions; they are
reserved words and must not be overwritten. Only a subset is of use to the KID user, and these are given with a full description or reference in the following section.For each identifier listed here there is a header indicating whether it is the name of a function or a variable, and giving an indication of the arguments expected by the function. The words Subr, Fsubr and Expr are used to mean:
A built-in function with special argument processing, e.g. it guarantees to process arguments from left to right, or it sometimes does not evaluate all of its arguments |
|
The functions marked with an (*) are described (or additional explanation is supplied) in the following section, all others are described in the ACORNSOFT book " LISP on the BBC Microcomputer".
In use, all of the functions described are used in the lower case form. The upper case form has been used to visually clarify the function names within the text.
Note:
(help <f/subr>) gives more information on any function. |
(ABS x) |
If x is numeric then the absolute value, |x|, of x is returned. If x is a string then the lower-case string is returned. If x is a list then ABS returns its length:
(ABS -4.5) = 4.5 (ABS "Guten Morgen") = "guten morgen" (ABS ´(a b c)) = 3 |
This function adds 1 and is equivalent to:
( plus x 1 ) |
(DEFUN function-name parameters body ...) |
DEFUN is a convenient way of defining functions. None of the arguments are evaluated. The use of DEFUN is exactly equivalent to
(SETQ function-name) ´(LAMBDA parameters body ...)) |
The value returned by DEFUN is the name of the function that has been defined. The second argument (parameters) is a list of arguments and local variables that the function uses. Any number of actions can be given for the function to carry out.
(DEFUN ADD2 (X) (PLUS X 2)) |
defines a function ADD2 by setting ADD2 to the value
(LAMBDA (X) (PLUS X 2)). (DEFUN PR_ADD2 (X (Y)) (SETQ Y (PLUS X 2)) (PRINT Y) Y) |
defines a function PR_ADD2 with local variable Y (initialized to NIL).
(DEFUN INCR (X (Y . 1)) (PLUS X Y)) |
defines a function INCR with optional parameter Y (default 1). Note: only constant values may be used as defaults.
(DEFUN ERR (MESS (SEV)) (PRINTC "error encountered") (PRINTC MESS) (COND ((NULL SEV) NIL) (T (PRINTC "severity: " SEV))) ) |
defines a function ERR with an optional parameter.
(DEFUN MY_PRINT X (LOOP (WHILE X) (PRIN1 (EVAL (CAR X))) (SETQ X (CDR X)) )) |
defines a function MY_PRINT which receives its arguments unevaluated and in a list.
This function forces real division, for example:
( divide x y ) |
( quotient ( plus x 0.0 ) y ) |
This is a generalized function to join two lists assumed to be the same length together pairwise with any binary function. The binary function is optional and defaults to the list operator with two arguments.
(entwine LIST LIST <binary op> ) |
(entwine ´(a b c) ´(1 2 3)) => ((a 1) (b 2) (c 3)) (entwine ´(a b c) ´(1 2 3) ´cons) => ((a . 1) (b . 2) (c . 3)) (entwine ´(a b c) ´(1 2 3) ´plus) => (a1 b2 c3) |
(EQUAL exp exp ...) |
The basic LISP function EQ compares two or more atoms for equality. When applied to list structures it checks if the pointers to them are identical. EQUAL compares list structures to see whether they have the same shape and the same atoms as leaves. EQUAL may have been defined as:
(DEFUN EQUAL (A B) (COND ((EQ A B) T) ((OR (ATOM A) (ATOM B)) NIL) ((EQUAL (CAR A) (CAR B)) (EQUAL (CDR A) (CDR B))) (T NIL))) |
This function applies a selective filter to a list identifying those to keep by element number. Positive indices count from the front, negative indices from the end.
(HELP), (HELP item), (HELP exp), (HELP item/expression item/expression) |
HELP provides information on the state of the system, commands,the various environments maintained (global, local, c, io and trace) and the values of functions and variables. Without argument HELP catalogues all items for which it can provide information. A second item or expression specifies the property in a property list. Items may contain wildcard characters.
This a simple function which inserts the specified value into the list m as the nth element. The abs of m is increased by one. It is assumed that:
1 <= n <= ( ( abs m ) + 1 ) |
( insert 1 ´( a b c d ) ´h ) => ( h a b c d ) ( insert 5 ´( a b c d ) ´h ) => ( a b c d h ) ( insert 3 ´( a b c d ) ´( h i ) ) => ( a b ( h i ) c d ) |
LET takes any number of arguments. The first is interpreted as a list of variables and initializations, the rest as forms to be evaluated. The variables list contains atoms or lists of two items. Atoms are variable names to be initialized to nil. The first element of a list is a variable name, the second its initialization value which is evaluated.
( let (a (b 5) (c (plus 3 5) ) ) ( printc "a "a "b "b "c "c )) "a nil b 5 c 8" |
(LOAD filename [mode] [handler]) |
The argument to LOAD should be the name of a file. LOAD reads the file and evaluates the LISP expressions in it. The value of LOAD is the value of the last expression in the file or UNDEFINED if an unexpected end of file was encountered. If the file is not found an attempt is made to open a system file of the same name. The second argument is optional and when provided may be one of:
reroute standard input to load file for EOF, GETCHAR, READ, READLINE |
A third, optional argument is an error handler to be executed if an error occurs during loading. if the handler returns NIL then loading of the file is abandoned, which is also the default for LOAD.
(DEFUN ignore () (PRINTC "ignoring loading error") T) (LOAD ´fred ignore) |
(LOAD ´fred T) |
If no file extension is given, then an extension of the type .lsp is assumed.
Pack groups elements of a list:
(pack 3 ´(0 0 0 0 0 1 0 0 2 0 0 3 0 0 4)) --> ( ( 0 0 0 ) ( 0 0 1 ) ( 0 0 2 ) ( 0 0 3 ) ( 0 0 4 ) ) |
If there are not enough elements available, the last element of the packed list is shorter:
(pack 3 ´(1 2 3 4)) --> ( ( 1 2 3 ) ( 4 ) ) |
(PLUS number number ...) |
PLUS returns the sum of all its arguments. PLUS can have any number of arguments. If one of the arguments is a string, then the result is the string concatenation of all arguments. The operator handles lists in a manner similar to DIFFERENCE.
(PLUS 6 2 -3.1) = 4.9 (PLUS ´hello blank ´dolly) = "hello dolly" (PLUS ´(1 2 3) ´5) = ´(6 7 8) (PLUS ´((1 2 3) (4 5 6)) ´(2 4)) = ´((3 4 5) (8 9 10)) |
See DIFFERENCE, MINUS and TIMES.
(QUIT) |
Leaves the Lisp interpreter and closes the journal file for the session. Note that an end-of-file encountered while reading from the standard input device has the same effect as QUIT.
Remainder has been overloaded to work on lists.
If two lists are passed as arguments then those elements which are common to both p and q are removed from p. The resultant p is returned.
This is a simple function which replaces the nth element of the list m with the specified value. The abs of m is unchanged. It is assumed that:
1 <= n <= ( abs m ) |
This is a general function to select the first or last n elements from a list. If n is negative the last n elements are selected. If the first argument is a list of integers then the selection proceeds by grouping subsequent elements of the data list in order.
This function subtracts 1 and is equivalent to:
( difference x 1 ) |
Any string contained in double quotes is turned into a quoted single identifier. Within double quotes, spaces and punctuation characters (with the exception of double quotes) do not have to be preceded by the escape character,
!
.
"123" = ´123 "temp.dat" = ´temp!.dat "zum Beispiel: " = ´zum! Beispiel!:! |
The double hyphen,
--
, introduces a comment which is terminated by the newline character.
<<< Error Codes in Parasolid LISP | Chapters | KID Examples >>> |