fork download
  1. ; Building a nests for the banana kiwi list (multidown)
  2. ; ------------------------------
  3. ; The Little Lisper 3rd Edition
  4. ; Chapter 5
  5. ; Exercise 3
  6. ; Common Lisp
  7. ; http://t...content-available-to-author-only...r.com/thelittlelisper
  8. ; http://t...content-available-to-author-only...t.com/2010/06/little-lisper-chapter-5-multichapter.html
  9. ; http://t...content-available-to-author-only...t.com/2010/06/little-lisper.html
  10. ; ------------------------------
  11. (setf x 'comma)
  12. (setf y 'dot)
  13. (setf a 'kiwis)
  14. (setf b 'plums)
  15. (setf lat1 '(bananas kiwis))
  16. (setf lat2 '(peaches apples bananas))
  17. (setf lat3 '(kiwis pears plums bananas cherries))
  18. (setf lat4 '(kiwis mangoes kiwis guavas kiwis))
  19. (setf l1 '((curry) () (chicken) ()))
  20. (setf l2 '((peaches) (and cream)))
  21. (setf l4 '())
  22. ; ------------------------------
  23.  
  24. ;note the usage of the list function to build lists - where quote is not sufficient
  25. (quote 'bob)
  26. (quote (quote 'bob))
  27. (list 'bob)
  28.  
  29. (defun multidown (lat)
  30. (cond
  31. ((null lat) '())
  32. (t
  33. (cons (list (car lat)) (multidown (cdr lat))))))
  34.  
  35. (print (multidown lat1))
  36. ;((BANANAS) (KIWIS))
  37. (print (multidown lat2))
  38. ;((PEACHES) (APPLES) (BANANAS))
  39. (print (multidown l4))
  40. ;()
  41.  
Success #stdin #stdout 0s 10592KB
stdin
Standard input is empty
stdout
((BANANAS) (KIWIS)) 
((PEACHES) (APPLES) (BANANAS)) 
NIL