Cadr of a list involving assoc function

Posted by user3619045 on Stack Overflow See other posts from Stack Overflow or by user3619045
Published on 2014-05-31T05:32:35Z Indexed on 2014/05/31 9:26 UTC
Read the original article Hit count: 151

Filed under:
|

I have looked around on the net and cant find an answer to my query. I would really appreciate if someone could provide a good answer without down rating this post.

In Lisp car, cdr are used on data mode like '(whatever here) which makes sense to me.

Now, in the book Land of Lisp the author is explaining how to build a text engine and suddenly he uses the following description to make a function.

(defun describe-location (location nodes)
  (cadr (assoc location nodes)))

Can I ask why is he doing a cadr on a list and how come it provides a response and not an error? shouldn't it be a data mode i.e with a quote in front of the opening bracket '(whatever here)?

and also why is he using assoc as in (assoc location nodes) and not (assoc 'garden *nodes*)

Isn't the second correct way to use assoc ? I may be missing the big picture and as such would really appreciate someone explaining these key points please.

Many thanks!

© Stack Overflow or respective owner

Related posts about lisp

Related posts about common-lisp