; Adding the nested numbers
; ------------------------------
; The Little Lisper 3rd Edition
; Chapter 6
; Exercise 6
; 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)
; ------------------------------
(defun addvec (vec)
  (cond 
   ((null vec) 0)
   (t (+ (car vec)(addvec (cdr vec))))))

(print (addvec '(1 2 3)))
;6

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

(defun list+ (vec)
  (cond 
   ((null vec) 0)
   ((notatom (car vec))
    (+ (list+ (car vec))
       (list+ (cdr vec))))
   (t (+ (car vec)(list+ (cdr vec))))))

(print (list+ '(1 2 3)))
;6
(print (list+ '(1 (2 (3)))))
;6
