CS116 - Artificial Intelligence
Spring, 2004
(updated 1/14/2004)

HW 1, Due Wed. Jan. 21 (2:00pm), 2004 (extended deadline)

For this assignment, submit two text files.  The first should answer #2 and consist of a trace of your interaction with the interpreter.  Name this file "hw1a.txt".  The second should only contain the various function definitions for #3 and 4 (and of course any comments and documentation that is appropriate).  Name this file "hw1b.lisp".  Submit these to the course WebCT site by 2pm on Friday.  The assignment will be graded on correctness, completeness, and coherence (style and elegance).

2.  Mentally evaluate the following expressions (in order) as if you were a lisp interpreter.  Then, using the lisp interpreter you have installed (or on pilot), evaluate them to confirm your mental evaluations.  (Show the evaluation.)
a.  (setq method1 '+)
b.  (setq method2 '-)
c.  (setq method method1)
d.  method
e.  (eval method)
f.  (setq method 'method1)
g.  method
h.  (eval method)
i.  (eval (eval '(quote method)))
j.  (list (eval method) 7 2)
k.  (eval (list (eval method) 7 2))

3.  Write recursive lisp functions for the following without using the obvious built-in functions:
a.  Reverse a given list: (reverse '(a b c)) --> (c b a)
b.  Return the length of a given list:  (length '(a b c))  -->  3
c.  Determine if an item is a member of a given list  (you may assume that the item is an atom, but feel free to extend your definition to handle both atoms and lists as the searched-for item):  (member 'b '(a b c))  -->  t
d.  "recursive"-member which finds the item at any depth of the given list:  (r-member 'x '(a (b c) (d (w x y)) e f))  -->  t

4.  Write lisp functions to compute the standard deviation of a list of numbers.  (The standard deviation is simply the square root of the variance of a sample.)  You may want to break this into functions to compute the sum of a list of numbers, the average of a list of numbers and perhaps the sum-or-squares or the squared difference from the mean.