Several functions are predefined in Sather Lisp. Since predefined functions are bound to ordinary symbols, (the values of) these symbols may be redefined if desired (and the old function is lost unless it is bound to another symbol, too). User defined functions may be added (or redefined, resp.) by binding lambda expressions to symbols (see Section 6). A list of all symbols known to the system is obtained using (symbols). The following table gives a brief definition of all predefined functions.
Expression Result Constraints
(+ arg0 arg1 [... argn]) (arg0 + arg1) + ... + argn (numbers only) (- arg0 arg1 [... argn]) (arg0 - arg1) - ... - argn (numbers only) (* arg0 arg1 [... argn]) (arg0 * arg1) * ... * argn (numbers only) (/ arg0 arg1 [... argn]) (arg0 / arg1) / ... / argn (numbers only) (% arg0 arg1 [... argn]) (arg0 % arg1) % ... % argn (numbers only) (^ arg0 arg1 [... argn]) (arg0 ^ arg1) ^ ... ^ argn (numbers only) (= arg0 arg1 [... argn]) arg0 = arg1 = ... = argn (numbers and strings only) (# arg0 arg1 [... argn]) arg0 # arg1 # ... # argn (numbers and strings only) (< arg0 arg1 [... argn]) arg0 < arg1 < ... < argn (numbers and strings only) (<= arg0 arg1 [... argn]) arg0 <= arg1 <= ... <= argn (numbers and strings only) (> arg0 arg1 [... argn]) arg0 > arg1 > ... > argn (numbers and strings only) (>= arg0 arg1 [... argn]) arg0 >= arg1 >= ... >= argn (numbers and strings only) (! arg) factorial of floor(arg) (numbers only) (floor arg) floor of arg (numbers only) (ceiling arg) ceiling of arg (numbers only) (car arg) head of arg (arg must be a list) (cdr arg) tail of arg (arg must be a list) (cons arg0 arg1) (arg0 . arg1) (atom arg) t if arg is not a pair, () otherwise (eq arg0 arg1) arg0 = arg1 'arg shortcut for (quote arg) (quote arg) returns arg without evaluation (eval arg) evaluates the value of arg (set sym arg) binds the value of arg to the symbol sym (setq arg0 arg1) binds the value of arg1 to the symbol value of arg1 (write arg) writes arg to stdout and returns arg (writeLn) starts a new line to stdout and returns () (lambda ...) see Section 6 (cond arg0 [arg1 ... argn]) each argument is considered to be a list consisting of a condition (which evaluates to nil or non_nil) and a sequence of expressions. cond evaluates the first sequence of expressions for which its condition is evaluated to a non_nil value. The result of cond is the last expression evaluated (see examples). (readFile arg) reads and evaluates file arg (arg must be a string) (tracer arg) arg = on: turns tracing output on and returns on arg # on: turns tracing output off and returns off (tracer) actual tracing mode (on or off) (symbols) returns list of all known symbols (exit) exits the interpreterNote: Use = for comparison of numbers and strings; eq does only a pointer comparison, thus (eq 1 1) # t!