fork download
  1. ; Get the variables passed into your expression DSL
  2. ; ------------------------------
  3. ; The Little Lisper 3rd Edition
  4. ; Chapter 7
  5. ; Exercise 8
  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-7-shadows.html
  9. ; http://t...content-available-to-author-only...t.com/2010/06/little-lisper.html
  10. ; ------------------------------
  11. (setf l1 '())
  12. (setf l2 '(3 + (66 6)))
  13. (setf aexp4 5)
  14. ; ------------------------------
  15.  
  16. (defun lookup (a lat)
  17. (cond
  18. ((null a) NIL)
  19. ((null lat) NIL)
  20. ((eq a (car (car lat)))
  21. (cdr (car lat)))
  22. (t
  23. (lookup a (cdr lat)))))
  24.  
  25. (print (lookup 'y '((x 1)(y 0))))
  26. ;0
  27.  
  28. (print (lookup 'x '((x 1)(y 0))))
  29. ;1
  30.  
  31. (print (lookup 'u '((u 1)(v 1))))
  32. ;1
  33.  
  34. (print (lookup 'y '()))
  35. ;NIL no answer
  36.  
Success #stdin #stdout 0.01s 10584KB
stdin
Standard input is empty
stdout
(0) 
(1) 
(1) 
NIL