Page 62 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 62
Introduction to Artificial Intelligence & Expert Systems
Notes (loop do ... until c) loop (do something until condition)
(loop with VAR = INITIAL-VALUE ... while loop (for "a la C" (while + initialisation))
CONDITION finally INCREMENT ...)
(loop for i from 1 to 10 by -1 do ...) loop (for each value in a numeric range, 1
decrement)
(loop for i from 1 to 10 do ...) loop (for each value in a numeric range, 1
increment (see also the entries about ranges))
(loop for i from 1 to 10 by 2 do ...) loop (for each value in a numeric range, free
increment)
(loop do ...) loop (forever loop)
(loop while c do ...) loop (while condition do something)
(case val multiple selection (switch)
((v1) ...)
((v2) ...)
(otherwise ...))
(progn ...) (prog1 ...) (prog2 ...) Sequence
Types
(declare (t v)) annotation (or variable declaration)
(deftype n () 't) Declaration
Object Oriented & Reflexivity
call-next-method accessing parent method
defclass defstruct class declaration
dispatching parameter current instance
type-of get the type/class corresponding to an
object/instance/value
find-method has the method
(defclass child (parent) ...) Inheritance
(method object para) method invocation
(method object) method invocation (with no parameter)
(make-instance class_name ...) object creation
Typep testing class membership
Package, Module
(defpackage p ...) Declare
(export 'name1 'name2) declare (selective export)
(use-package 'p) import (everything into current namespace)
(require 'p) import (package (ie. load the package))
(import '(p:name1 p:name2)) import (selectively)
:::(5) package scope
Strings
char, aref, schar, svref accessing n-th character
Aref accessing n-th character
code-char ascii to character
Contd...
56 LOVELY PROFESSIONAL UNIVERSITY