LISP Homework Due Sept. 30

Your task is to be able to do the following with or without a computer. Hand in a screen printout and hand written evaluations, showing your work if you use CLisp. You may find the linked  practice elements helpful. (Show definitions and interactions for Dr. Scheme)

CLisp

With a computer: logon to server:  type clisp
You can execute any lisp function, just not save stuff for later.
To get out of trouble  d  or quit 

1.  Evaluate as LISP would the function:

(Note at bottom differences for Dr. Scheme)

(defun  hw (n)

             (cond ((null n) nil)     ((= n 0 ) 1) ((< n 0) 1)

                       (t (* n (hw (- n 1))))))

for

   a.  (hw 3)

   b.  (hw 4)

   c.  (hw -5)

   d.  (hw 0)
 
 

2.  Given (setq List '((a b) c (d (e f)) g)),  Evaluate:
 
 

   a. (car List)

   b. (cdr List)

   c. (cadr List)

   d. (caddr List)

   e. (caaddr List)
 
 

3.  Evaluate

   a.  (cons 'a '(b c))

   b.  (cons '(a f)  '(d e))

   c.  (cons 'a  'b)
 
 

4.  Evaluate as LISP would

      (defun app ( L M)

                (cond ((null L) M)

                (t  (cons (car L)   (app (cdr L) M)) )) )

for

       a.   (app '(dog)   '(and cat))



       b.   (app 'dog '(and cat))
5.  (Write a function to remove a given atom from a list of atoms.
(remoo L 5)  would remove the atom 5 from the list L,   (remoo L y)
would remove the atom represented by y from the list L.
Note Dr. Scheme requires fulls Scheme language and null?  and else instead of t
defun may be expanded to (define (lambda  or just stay as (define
'|dog| means atom -- Dr. Scheme wants 'dog for same thing.
You may save stuff in top window of Dr. Scheme