Page 60 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 60
Introduction to Artificial Intelligence & Expert Systems
Notes 4.2 Syntax and Numeric Functions
The two fundamental pieces of LISP syntax are the idea of a list of things and the dotted pair:
For any set of strings X, list_of(X)::=”(“ # X “)”,
For any set of strings X, dotted_pair(X)::=”(“ X dot X “)”.
A dotted pair is the external image of a node in an internal data structure with two components
called “car” and “cdr” for historical reasons.
Did u know? Each component in the pair points at an atomic item or another list.
Each list is coded internally as dotted pairs:
(A) = (A.NIL).
(A B) = (A.(B.NIL)).
(A B C) = (A.(B.(C.NIL))).
(A B C D ... Y Z) = (A.(B.(C.(.D ... (Y. (Z. NIL)) ...).
After the lexical analysis the interpreter parses input as a list_structure before evaluating it. A
list_structure is empty, or a dotted_pair, or an atom, or any number of lists inside a pair of
parenthesis. We often call a list structure a list for short. But always be careful to distinguishing
‘a list of numbers’ from a ‘list structure of numbers’
list_structure::=atom | dotted_pair(list_structure) | list_of(list_structure).
Notes In old LISP, commas were optional separators in lists but not in XLISP and Scheme.
The separating spaces, tabs, etc. in a list are all sieved out by the lexical scan. This scan also
removes comment lines that start with a semicolon [ comment in lisp.lexemes ]
atom::= [ atom in lisp. lexemes ]
The “Unknowns” below indicate that an entry is incomplete.
either the entry exist in the language,
either the entry doesn’t exist in the language. The entry will be marked as such and won’t
appear as missing anymore.
Category: Object Oriented, Dynamically typed, Functional
Various
nothing needed breaking lines (useful when end-of-line and/or
indentation has a special meaning)
#| ... |#(1) commenting (nestable)
; commenting (until end of line)
< > <= >= Comparison
min/max comparison (min/max (binary or more))
(defun f (para1 para2) "..." ...) documentation comment
Equal equality/inequality (deep)
Equalp equality/inequality (deep)
eq, eql equality/inequality (shallow)
Contd...
54 LOVELY PROFESSIONAL UNIVERSITY