(cond ((null list) nil)
((not (listp list)) list)
(t (append (deep-reverse (cdr list)) (list (deep-reverse (car list)))))))
2.28
(defun fringe(list)
(cond ((null list) nil)
((not (consp list)) (list list))
(t (append (fringe (car list))
(fringe (cdr list))))))
2.29
2.30
(defun square-tree(list)
(cond ((null list) nil)
((not (listp list)) (list (* list list)))
(append (square-tree (car list)) (square-tree (cdr list)))))
(defun square-treev2(list)
(defun squarev2(x)
(cond ((null x) nil)
((not (listp list)) (list (* list list)))
(append (squarev2 (car list)) (squarev2 (cdr list)))))
(mapcar #'squarev2 list))
2.32
((not (listp list)) (list (* list list)))
(append (square-tree (car list)) (square-tree (cdr list)))))
(defun square-treev2(list)
(defun squarev2(x)
(cond ((null x) nil)
((not (listp list)) (list (* list list)))
(append (squarev2 (car list)) (squarev2 (cdr list)))))
(mapcar #'squarev2 list))
2.32
(defun subsets (s)
(if (null s)
(list nil)
(let ((rest (subsets (cdr s))))
(append
rest
(mapcar (lambda (r)
(cons (car s) r))
rest)))))
(if (null s)
(list nil)
(let ((rest (subsets (cdr s))))
(append
rest
(mapcar (lambda (r)
(cons (car s) r))
rest)))))
No comments:
Post a Comment