Page 63 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 63
Unit 4: LISP
#\z character "z" Notes
char-code character to ascii
(coerce e 'string) convert something to a string (see also string
interpolation)
Subseq extract a substring
Search locate a substring
(search substring string:from-end t) locate a substring (starting at the end)
all strings allow multi-line strings multi-line
(with-standard-io-syntax (write obj serialize (marshalling)
stream))
Write simple print (on any objects)
Print simple print (on any objects)
princ prin1 simple print (on any objects)
write-string simple print (on strings)
Format simple print (printf-like)
Format sprintf-like
concatenate string concatenation
equal, equalp string equality & inequality
Length string size
"~%" strings (end-of-line (without writing the real CR
or LF character))
"..." strings (with no interpolation of variables)
(with-standard-io-syntax (read obj unserialize (un-marshalling)
stream))
char-upcase/char-downcase upper/lower case character
string-upcase/string-downcase uppercase/lowercase/capitalized string
Booleans
Nil false value
not logical not
or/and logical or/and (short circuit)
T true value
anything not false true value
boolean type name
Bags and Lists
Cons adding an element at the beginning (list cons)
(return the new list (no side-effect))
Push adding an element at the beginning (list cons)
(side-effect)
Cdr all but the first element
Reduce f(... f(f(init, e1), e2) ..., en)
(reduce f '(e1 e2 ... en):from-right f(e1, f(e2, ... f(en, init) ...))
t:initial-value init)
Find find an element
Contd...
LOVELY PROFESSIONAL UNIVERSITY 57