Académique Documents
Professionnel Documents
Culture Documents
Program Structure:
Collection of function definitions, each of the form:
example:
(defun second (lst)
(car (cdr lst)))
Comments
Built-in functions
Predicate functions
the empty list [() or nil] represents false, and t represents true
(although, much like in C, anything other than the empty list is considered “true” in Boolean expressions)
Arithmetic functions
(+ x y) ; returns the sum of x and y (can have multiple arguments)
; (- 2 3) => -1, (- 3 4 5) => -6
(- x y) ; returns the difference of x and y (can have multiple arguments)
; (+ 2 3) => 5, (+ 3 4 5) => 12
(* x y) ; returns the product of x and y (can have multiple arguments)
; (* 3 4 5) => 60
(/ x y) ; returns the quotient of x and y (result is a rational number)
; (/ 4 8) => 1/2, (/ 9 6 5) => 3/10
(rem x y) ; returns the remainder of x/y
Control flow functions:
example:
(cond ((equal a 0) 0)
((< a 0) (- 0 a))
(t a))
Loading Programs
(load “filename”)
example:
(load “test.lsp”)
Exiting Interpreter
(exit)
Example Functions