CS 365 Homework 4 Answers


The following are typical correct answers; there are others.
9-12
(defun remassoc (p a)
  (cond ((null a) nil)
        ((eq p (caar a)) (cdr a))
        (t (cons (car a) (remassoc p (cdr a)) )) ))
10-6
(defun append-red (L)
  (if (null L)
      nil
      (append (car L) (append-red (cdr L)) )) )
10-10
(defun count (L)
  (cond ((null L) 0)
        ((atom L) 1)
        (t (plus (count (car L)) (count (cdr L)) )) ))
10-14
(defun filter (p x)
  (cond ((null x) nil)
        ((p (car x)) (cons (car x) (filter p (cdr x)) ))
        (t (filter p (cdr x)) )) )
10-19
(defun pairlis (u v w)
  (append (mapcar2 'list u v) w))
10-35
mean = (divide sign) ° [/+, length]


  Return to MacLennan's home page
 
Send mail to Bruce MacLennan / MacLennan@cs.utk.edu

Last updated: Mon Feb 11, 2002 Thu Apr 25 14:32:41 EDT 2002