List of Parasolid LISP Functions   

<<< Error Codes in Parasolid LISP Chapters KID Examples >>>

Contents

[back to top]


D.1 PARASOLID LISP functions

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:

 

Subr:

A built-in function which processes its arguments normally

Fsubr:

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

Expr:

A function defined in LISP, not in C

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.

 

Function

Type

*ADD1

Expr

ADDRESS

Variable

AND

Fsubr

*ABS

Subr

APPEND

Subr

APPLY

Fsubr

ASSOC

Subr

ATOM

Subr

BACK

Variable

BAND

Fsubr

BLANK

Variable

BNOT

Subr

BOR

Fsubr

BYTE

Variable

CALL

Fsubr

CAR

Subr

CATCH

Fsubr

CDR

Subr

CHAR

Variable

CHARACTER

Subr

CHARP

Subr

CHARS

Subr

CLOCK

Subr

CLOSE

Subr

COND

Fsubr

CONS

Subr

CFSUBRP

Subr

CSUBRP

Subr

CR

Variable

CTIME

Subr

CVARP

Subr

DECIMALWIDTH

Variable

DECODE

Fsubr

*DEFUN

Fsubr

DEFPROC

Fsubr

DELETE

Subr

DIFFERENCE

Fsubr

*DIVIDE

 

DOLLAR

Variable

DOUBLE

Variable

EDIT

Expr

ELEMENT

Subr

ENCODE

Fsubr

*ENTWINE

 

EOF

Subr

EQ

Fsubr

*EQUAL

Fsubr

ERROR

Subr

ERRORSET

Fsubr

EVAL

Subr

EXPLODE

Subr

F

Variable

*FILTER

 

FLATTEN

Subr

FLOAT

Variable

FSUBRP

Subr

FUNCTION

Variable

GCTIME

Subr

GET

Subr

GETCHAR

Subr

GREATERP

Fsubr

*HELP

Fsubr

IMPLODE

Subr

*INSERT

 

INT

Variable

JOURNAL

Subr

LAMBDA

Special identifier

LAST

Subr

LASTCDR

Subr

LESSP

Fsubr

*LET

 

LINEWIDTH

Variable

LIST

Subr

LISTP

Subr

*LOAD

Subr

LOGICAL

Variable

LOOP

Fsubr

LPAR

Variable

MAP

Expr

MAPC

Expr

MEMBER

Subr

MESSOFF

Subr

MESSON

Subr

MINUS

Subr

MINUSP

Expr

NIL

Special identifier

NOT

Subr

NULL

Subr

NUMBERP

Subr

OBLIST

Subr

ONEP

Expr

OPEN

Subr

OR

Fsubr

ORDINAL

Subr

PERIOD

Variable

PLIST

Subr

*PLUS

Fsubr

POINTER

Subr

PRIN

Subr

PRINC

Subr

PRINT

Subr

PRINTC

Subr

PROGN

Fsubr

PROMPT

Variable

PUT

Subr

*QUIT

Subr

QUOTE

Fsubr

QUOTIENT

Fsubr

READ

Subr

READLINE

Subr

RECLAIM

Subr

*REMAINDER

Expr

REMPROP

Subr

*REPLACE

 

REPLICATE

Subr

RESET

Subr

REVERSE

Subr

RPAR

Variable

RPLACA

Subr

RPLACD

Subr

RPLACV

Fsubr

SED

Expr

*SELECT

 

SET

Fsubr

SETQ

Fsubr

SHORT

Variable

SPECIAL

Variable

SPRINT

Subr

STRING

Variable

STRUCT

Subr/Variable

*SUB1

Expr

SUBRP

Subr

SUBST

Subr

T

Special identifier

THROW

Fsubr

TIME

Subr

TIMES

Fsubr

TRACE

Fsubr

TRUNC

Subr

UNDEFINED

Special identifier

UNION

Subr

UNTIL

Fsubr

UNTRACE

Fsubr

VDU

Subr

VOID

Variable

WHILE

Fsubr

WHITESPACE

Variable

WRITE

Subr

WRITEO

Subr

ZEROP

Expr

*

Subr

!

Special character

" <string> "

Special characters

--

Special characters

@

Special character

[back to top]


D.2 PARASOLID LISP function descriptions

ABS - Subr

 

(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

ADD1

This function adds 1 and is equivalent to:

 

( plus x 1 )

DEFUN - Fsubr

 

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

Examples:

 

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

DIVIDE

This function forces real division, for example:

 

( divide x y )

and is equivalent to:

 

( quotient ( plus x 0.0 ) y )

ENTWINE

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.

General form:

 

(entwine LIST LIST <binary op> )

Example:

 

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

 

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

FILTER

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.

Example:

 

( filter ´( 1 3 5 7 ) ´( a b c d e f ) ) => ( a c e nil )
( filter ´( -1 -3 -5 -7 ) ´( a b c d e f ) ) => ( f d b nil )
( filter 5 ´( a b c d e f ) ) => e
( filter -5 ´( a b c d e f ) ) => b
( filter 99 ´( a b c d e f ) ) => nil
( filter -99 ´( a b c d e f ) ) => nil

HELP - Fsubr

 

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

Examples:

 

(HELP cons)         --- get information on system function cons
(HELP con*)          --- list identifiers, functions
                         beginning with ´con´
(HELP fred)          --- get environment and value of fred
(HELP fred *)        ---  list all properties of fred
(HELP *create)       --- list all identifiers containing 
                         create property
(HELP (eval ´handle)) --- get information on file handle

INSERT

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 )

Example:

 

( 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

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.

Example:

 

( let (a (b 5) (c (plus 3 5) ) )
  ( printc "a "a "b "b "c "c ))	
  "a nil b 5 c 8"
Note: Initializations in LET are in "in parallel", so later initializations cannot make use of earlier ones.

If this functionality is required, use the function LET*. LET* is identical to LET except for allowing later initializations to make use of earlier ones.

LOAD - Subr

 

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

 

Argument

Description

REFLECT:

print out all S expressions read

VERIFY:

print out expressions read and evaluated

REPLAY:

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.

Examples:

 

(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

Pack groups elements of a list:

Examples:

 

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

 

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

Examples:

 

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

 

(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

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.

REPLACE

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 )

Example:

 

( replace 1 ´( a b c d ) ´h ) => ( h b c d )
( replace 4 ´( a b c d ) ´h ) => ( a b c h )
( replace 3 ´( a b c d ) ´( hi ) ) => ( a b ( h i ) d )
( replace 2 ´(( a b c ) ( d e f ) ( g h i )) ´( j k ))
                       => (( a b c ) ( j k ) ( g h i ))

SELECT

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.

Example:

 

( select 3 ´( a b c d e f ) ) => ( a b c )
( select -3 ´( a b c d e f ) ) => ( d e f )
( select ´( 3 3 ) ´( a b c d e f ) ) => ( ( a b c ) ( d e f ) )
( select ´( 1 2 3 ) ´( a b c d e f ) ) 
                                => ( ( a ) ( b c ) ( d e f ) )
( select ´( -1 -2 -3 ) ´( a b c d e f ) ) 
                                 => ( ( f ) ( d e ) ( a b c ) )

SUB1

This function subtracts 1 and is equivalent to:

 

( difference x 1 )

"<string>" special character

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, ! .

Example:

 

"123" = ´123
"temp.dat" = ´temp!.dat
"zum Beispiel: " = ´zum! Beispiel!:!

-- special character

The double hyphen, -- , introduces a comment which is terminated by the newline character.

 

[back to top]

<<< Error Codes in Parasolid LISP Chapters KID Examples >>>