diff --git a/chapter2.lisp b/chapter2.lisp index f39c12a..fa14ef6 100644 --- a/chapter2.lisp +++ b/chapter2.lisp @@ -129,3 +129,15 @@ and upper bound." (if (null l) () (append (reverse-user (cdr l)) (list (car l))))) + +;; Exercise 2.21 +(defun square-list (items) + (if (null items) + nil + (cons (* (car items) (car items)) (square-list (cdr items))))) + +(defun square-list-map (items) + (map 'list #'(lambda (x) (* x x)) items)) + +(defun square-list-mapcar (items) + (mapcar #'(lambda (x) (* x x)) items))