; What does this function g* do?
; ------------------------------
; The Little Lisper 3rd Edition
; Chapter 6
; Exercise 7
; 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 g* (lvec acc)
(cond
((null lvec) acc)
((atom (car lvec))
(g* (cdr lvec)(+ (car lvec) acc)))
(t (g* (car lvec)(g* (cdr lvec) acc)))))
(print (g* '(1 (2 (3))) 0))
;6
'This takes a list of numbers and adds them into the accumulator (acc)
OyBXaGF0IGRvZXMgdGhpcyBmdW5jdGlvbiBnKiBkbz8KOyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KOyBUaGUgTGl0dGxlIExpc3BlciAzcmQgRWRpdGlvbgo7IENoYXB0ZXIgNgo7IEV4ZXJjaXNlIDcKOyBDb21tb24gTGlzcAo7IGh0dHA6Ly90Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5yLmNvbS90aGVsaXR0bGVsaXNwZXIKOyBodHRwOi8vdC4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4udC5jb20vMjAxMC8wNi9saXR0bGUtbGlzcGVyLWNoYXB0ZXItNi1vaC1teS1nYXdkLWl0cy5odG1sCjsgaHR0cDovL3QuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnQuY29tLzIwMTAvMDYvbGl0dGxlLWxpc3Blci5odG1sCjsgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCihzZXRmIGwxICcoKGZyaWVkIHBvdGF0b2VzKShiYWtlZCAoZnJpZWQpKSB0b21hdG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