(defun filter (list function) ;; returns a list of elements of list for which function is true. (cond ((null list) nil) ((funcall function (car list)) (cons (car list) (filter (cdr list) function))) (t (filter (cdr list) function)))) (defun integers (min max) (if (> min max) nil (cons min (integers (1+ min) max)))) (defun mymyreduce (function final list) (if (null list) final (funcall function (car list) (myreduce function final (cdr list))))) (defun sumlist (list) ;; returns the sum of the list elements (myreduce #'+ 0 list)) (defun mullist (list) ;; returns the sum of the list elements (myreduce #'* 1 list)) (defun copylist (list) ;; copies the top level of a list (myreduce #'cons nil list)) (defun appendlist (list) ;; appends all of the sublists in a list (myreduce #'append nil list)) (defun make-counter () (let ((count 0)) (lambda () (setf count (1+ count))))) (defun make-counter2 (&optional (increment 1)) (let ((count 0)) (lambda () (setf count (+ count increment)))))