; 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))
OyBGaW5kaW5nIHRoZSBoaWRkZW4gY2hpbGkgYW5kIHNlcGFyYXRpbmcgdGhlbSBvdXQKOyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KOyBUaGUgTGl0dGxlIExpc3BlciAzcmQgRWRpdGlvbgo7IENoYXB0ZXIgNgo7IEV4ZXJjaXNlIDEKOyBDb21tb24gTGlzcAo7IGh0dHA6Ly90Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5yLmNvbS90aGVsaXR0bGVsaXNwZXIKOyBodHRwOi8vdC4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4udC5jb20vMjAxMC8wNi9saXR0bGUtbGlzcGVyLWNoYXB0ZXItNi1vaC1teS1nYXdkLWl0cy5odG1sCjsgaHR0cDovL3QuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4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