(defun count-atoms (x) (cond ((null x) 0) ;; No more children. ((not (listp x)) 1) ;; Terminal node. (t (+ (if (atom (first x)) 1 (count-atoms (first x))) ;; Break the problem down into two subproblems. (count-atoms (rest x)))))) (defun last5 (x) (cond ((null (rest (rest (rest (rest (rest x)))))) x) (t (last5 (rest x)last5)))) (defun flip (x) (list (first x) (if (atom (third x)) (third x) (flip (third x))) (if (atom (second x)) (second x) (flip (second x))))) (defun funny_first (x) (mapcar #'(lambda (y) (first y)) x)) (defun funny_last (x) (mapcar #'(lambda (y) (first (last y))) x)) (defun funny_len (x) (apply #'+ (mapcar #'(lambda (y) (length y)) x))) (defun funny_sum (x) (apply #'+ (mapcar #'(lambda (y) (apply #'+ y)) x))) (defun ListNonNumbers (x) (mapcan #'(lambda (y) (if (numberp y) nil (list y))) x)) (defun AddNumbers (x) (apply #'+ (mapcar #'(lambda (y) (if (numberp y) y 0)) x))) (defun d_shuffle (l) (do ((newl nil) (i 15 (- i 1))) ((< i 0) newl) (setf newl (cons (nth i l) (cons (nth (+ i 16) l) newl)))))