whilemacro (test do &body body)
Execute body while the test is true.
for-eachmacro (var in list do &body body)
Execute body for each element of list. VAR can be a list or tree of variables, in which case the elements are destructured.
formacro (var = start to end do &body body)
Execute body with var bound to succesive integers.
deletefmacro (item sequence &rest keys &environment env)
Destructively delete item from sequence, which must be SETF-able.
define-if-undefinedmacro (&rest definitions)
Use this to conditionally define functions, variables, or macros that may or may not be pre-defined in this Lisp. This can be used to provide CLtL2 compatibility for older Lisps.
Is this a list of 2 or more elements?
Is this a list of exactly one element?
Return some element of the list, chosen at random.
mappendfunction (fn &rest lists)
Apply fn to respective elements of list(s), and append results.
starts-withfunction (list element)
Is this a list that starts with the given element?
Return the last element of a list.
Move the first element to the end of the list.
Move the last element to the front of the list.
Transpose a matrix represented as a list of lists. Example: (transpose '((a b c) (d e f))) => ((a d) (b e) (c f)).
reuse-consfunction (x y x-y)
Return (cons x y), or reuse x-y if it is equal to (cons x y)
make-expfunction (op &rest args)
Operator of an expression
Arguments of an expression
Convert a fully parenthesized prefix expression into infix notation.
insert-betweenfunction (item list)
Insert item between every element of list.
xytype (x y)
A two-dimensional (i.e. x and y) point.
Is the argument a 2-D point?
@function (x y)
Create a 2-D point
xy-equalfunction (p q)
xy-addfunction (p q)
Add two points, component-wise.
xy-distancefunction (p q)
The distance between two points.
x+y-distancefunction (p q)
The 'city block distance' between two points.
xy-betweenfunction (xy1 xy2 xy3)
Predicate; return t iff xy1 is between xy2 and xy3. Points are collinear.
rotatefunction (o a b c d)
insidefunction (l xmax ymax)
Is the point l inside a rectangle from 0,0 to xmax,ymax?
Numerical average (mean) of a list of numbers.
running-averagefunction (avg new n)
Calculate new average given previous average over n data points
sumfunction (numbers &optional key)
Add up all the numbers; if KEY is given, apply it to each number first.
betweenfunction (x y z)
Predicate; return t iff number x is between numbers y and z.
rms-errorfunction (predicted target)
Compute root mean square error between predicted list and target list
ms-errorfunction (predicted target)
Compute mean square error between predicted list and target list
boolean-errorfunction (predicted target)
dot-productfunction (l1 l2)
iotafunction (n &optional start-at)
Return a list of n consecutive integers, by default starting at 0.
random-integerfunction (from to)
Return an integer chosen at random from the given interval.
normalfunction (x mu sigma)
sample-with-replacementfunction (n population)
sample-without-replacementfunction (n population &optional m)
fuzzfunction (quantity &optional proportion round-off)
Add and also subtract a random fuzz-factor to a quantity.
round-offfunction (number precision)
Round off the number to specified precision. E.g. (round-off 1.23 .1) = 1.2
nothingfunction (&rest args)
Don't do anything, and return nil.
declare-ignorefunction (&rest args)
Ignore the arguments.
truefunction (&rest args)
Always return true.
falsefunction (&rest args)
Always return false.
requiredfunction (&optional msg &rest args)
If this ever gets called, it means something that was required was not supplied. Use as default value for &key args or defstruct slots.
Coerce argument to a string.
concat-symbolfunction (&rest args)
Concatenate the args into one string, and turn that into a symbol.
print-gridfunction (array &key stream key width)
Print the contents of a 2-D array, numbering the edges.
print-centeredfunction (string width &optional stream)
Print STRING centered in a field WIDTH wide.
print-repeatedfunction (string n &optional stream)
Print the string n times.
print-dashesfunction (width &optional stream separate-line)
Print a line of dashes WIDTH wide.
Make a copy of an array.
copy-subarrayfunction (a b indices dim)
Convert a multi-dimensional array to a vector with the same elements.
plot-alistfunction (alist file)
copy-hash-tablefunction (h1 &optional copy-fn)
Convert a hash table into a list of (key . val) pairs.
hprintfunction (h &optional stream)
prints a hash table line by line
composefunction (f g)
Return a function h such that (h x) = (f (g x)).
the-biggestfunction (fn l)
the-biggest-random-tiefunction (fn l)
the-biggest-thatfunction (fn p l)
the-smallestfunction (fn l)
the-smallest-random-tiefunction (fn l)
the-smallest-thatfunction (fn p l)
dprintfunction (&rest args)
Echo all the args when *debugging* is true. Return the first one.
deftestmacro (name &rest examples)
Define a set of test examples. Each example is of the form (exp test) or (exp). Evaluate exp and see if the result passes the test. Within the test, the result is bound to *. The example ((f 2))) has no test to fail, so it alweays passes the test. But ((+ 2 2) (= * 3)) has the test (= * 3), which fails because * will be bound to the result 4, so the test fails. Call (TEST name) to count how many tests are failed within the named test. NAME is the name of an aima-system.
add-testfunction (name examples)
The functional interface for deftest: adds test examples to a system.
testfunction (&optional name print?)
Run a test suite and sum the number of errors. If all is well, this should return 0. The second argument says what to print: nil for nothing, t for everything, or FAIL for just those examples that fail. If there are no test examples in the named system, put the system has other systems as parts, run the tests for all those and sum the result.
test-examplefunction (example &optional print?)
Does the EXP part of this example pass the TEST?
search-tree-nodetype (value num-elements key parent leftson rightson)
node for binary search tree
make-search-treefunction (root-elem root-key)
return dummy header for binary search tree, with initial element root-elem whose key is root-key.
create-sorted-treefunction (list-of-elems key-fun)
return binary search tree containing list-of-elems ordered according tp key-fun
Predicate of search trees; return t iff empty.
return leftmost descendant of tree-node
return rightmost descendant of header
return least element of binary search tree; delete from tree as side-effect
return largest element of binary search tree; delete from tree as side-effect
return least key of binary search tree; no side effects
return least key of binary search tree; no side effects
insert-elementfunction (element parent key &optional direction)
insert new element at proper place in binary search tree
randomized-insert-elementfunction (element parent key &optional direction)
insert new element at proper place in binary search tree -- break ties randomly
randomized-pushfunction (element list)
return list with element destructively inserted at random into list
find-elementfunction (element parent key &optional direction)
return t if element is int tree
delete-elementfunction (element parent key &optional error-p)
delete element from binary search tree
return inorder-successor of tree-node assuming it has a right son
return list of elements in tree
qtype (key last elements)
Are there no elements in the queue?
Return the element at the front of the queue.
Remove the element from the front of the queue and return it.
enqueue-at-frontfunction (q items)
Add a list of items to the front of the queue.
enqueue-at-endfunction (q items)
Add a list of items to the end of the queue.
enqueue-by-priorityfunction (q items key)
Insert the items by priority according to the key function.
heap-valfunction (heap i key)
heapifyfunction (heap i key)
Assume that the children of i are heaps, but that heap[i] may be larger than its children. If it is, move heap[i] down where it belongs. [Page 143 CL&R].
heap-extract-minfunction (heap key)
Pop the best (lowest valued) item off the heap. [Page 150 CL&R].
heap-insertfunction (heap item key)
Put an item into a heap. [Page 150 CL&R].
make-heapfunction (&optional size)
heap-sortfunction (numbers &key key)
Return a sorted list, with elements that are < according to key first.
with-simple-restartmacro (restart &rest body)
Like PROGN, except provides control over restarts if there is an error.
destructuring-bindmacro (lambda-list list &body body)
Bind the variables in lambda-list to the result list and execute body.
defstructuremacro (type-and-args &rest slots)
This is just like DEFSTRUCT, except it keeps track of :include types, for the benefit of METHOD-FOR, and it makes printing go through PRINT-STRUCTURE.
print-structuremethod ((structure t) stream)
Print a structure. You can specialize this function. It will be called to print anything defined with DEFSTRUCTURE.
defmethodmacro (name ((var class) &rest other-args) &rest body)
This version of DEFMETHOD is like the CLOS version, except it only dispatches on the first argument, and it only handles structures and some built-in types, not classes.
Define NAME to be a generic function.
Find the most specific supertype of this type.
call-method-forfunction (name type var args)
Find the method for this type, following :supertype links if needed.
|AIMA Home||Authors||Lisp Code||AI Programming||Instructors Pages|