fork download
  1. ; Can you rewrite your function to map it to a list?
  2. ; ------------------------------
  3. ; The Little Lisper 3rd Edition
  4. ; Chapter 9
  5. ; Exercise 1
  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-9-lamdba-ultimate.html
  9. ; http://t...content-available-to-author-only...t.com/2010/06/little-lisper.html
  10. ; ------------------------------
  11.  
  12. (defun map_ (l func)
  13. (cond
  14. ((null l) NIL)
  15. (t (cons (funcall func (car l))
  16. (map_ (cdr l) func)))))
  17.  
  18. ;firsts
  19. (print (map_ '((paella spanish)(wine red)(and beans)) #'car))
  20. ;(PAELLA WINE AND)
  21.  
  22. (setf spanish-food '((paella spanish)(wine red)(and beans)))
  23.  
  24. (print (map_ spanish-food #'car))
  25. ;(PAELLA WINE AND)
  26.  
  27. ;seconds
  28. (defun seconds-closure (l)
  29. (car (cdr l)))
  30.  
  31. (print (map_ spanish-food #'seconds-closure))
  32. ;(SPANISH RED BEANS)
  33.  
  34.  
  35.  
Success #stdin #stdout 0.01s 10592KB
stdin
Standard input is empty
stdout
(PAELLA WINE AND) 
(PAELLA WINE AND) 
(SPANISH RED BEANS)