

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































Valid objects (S-expression)
Valid objects (S-expression)
(sqrt 4) 2
(sqrt x) Error: The variable X is unbound.
(+ (sqrt 4) 4.0)
(setq x 3.0)
x
(setq y x)
; the value of x is assigned as the value of y
y
(+ x y)
Functions:
( cons 'x L) ; insert symbol x at the front of list L, which is (X A B C) ; (A B C) - >( list 'a 'b 'c) ; making a list with the arguments as its elements (A B C) ; if a, b, c have values A, B, C, then (list a b c) ; returns list (A B C) - >( append '(a b) '(c d)) (A B C D) ; appends one list in front of another
Functions: (cont’)
Functions (cont’)
Predicates
predicate is false, T or anything other than NIL, otherwise
Defining LISP functions
(defun y-plus (x) (+ x y)) ;definition of y-plus
(setq y 2) (y-plus 23) 25