{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 0218_note - 2/18 2010 S-expressions All lisp expressions...

This preview shows pages 1–2. Sign up to view the full content.

2/18 2010 S-expressions All lisp expressions are S-expressions are of two kinds 1 atoms (e.g numbers, symbols) 2. non-empty lists(e.g, (CAT DOG(27 CAT))is a list of 3 elements) S-expressions are used (a) as Lisp code – as expressions to be evaluated by Lisp. Ex: (Sqrt(+ (* 3 2 ) (- 4 1))) S-expressions that are meant to be evaluated by Lisp are called forms . Every form is an S-expression But most S-expressions cannot be forms. Ex: (cat dog (27 cat)) is a list that cannot be a form However, (cat dog (cat 27)) is a possible form. It could be the Lisp version of a Java expression cat(dog, cat(27)) (b) as Lisp data The value of any Lisp variable or, more generally, any Lisp form, is always an S- expression. Atoms: (i) numeric atoms(or numbers) There are 4 kinds of numbers: 1 integers (e.g. 34567) 2 ratios (e.g. 31/5) In fact, integers are just ratios that have 1 as their denominator) 3 floating-point numbers (e.g. -2.17) computation subject to rounding error…. 4 complex numbers (e.g. #C(3.1 2.7)) means 3.1+2.7 sqrt(-1) 3.1+2.7i (ii)Symbolic atoms(or symbols) Ex: + CAT X DEFUN DOG17

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}