; Finding the hidden chili and separating them out
; ------------------------------
; The Little Lisper 3rd Edition
; Chapter 6
; Exercise 1
; Common Lisp
; http://t...content-available-to-author-only...r.com/thelittlelisper
; http://t...content-available-to-author-only...t.com/2010/06/little-lisper-chapter-6-oh-my-gawd-its.html
; http://t...content-available-to-author-only...t.com/2010/06/little-lisper.html
; ------------------------------
(setf l1 '((fried potatoes)(baked (fried)) tomatoes))
(setf l2 '(((chili) chili (chili))))
(setf l3 '())
(setf lat1 '(chili and hot)) 
(setf lat2 '(baked fried)) 
(setf a 'fried)
; ------------------------------

(atom 'chili)
(atom '(chili))
(atom (car '(chili)))
(consp (car l2))

(defun notatom (lat)
  (not (atom lat)))

(notatom 'a)
(notatom '(a))

(defun down* (lat)
  (cond
   ((null lat) '())
   ((notatom (car lat))
    (cons (down* (car lat))
            (down* (cdr lat))))
   (t (cons (list (car lat))
            (down* (cdr lat))))))

(print (down* (list 'bob)))
;((BOB))

(print (down* l2))
;((((CHILI)) (CHILI) ((CHILI))))

(print (down* l3))
;NIL;

(print (down* lat1))
;((CHILI) (AND) (HOT))
