From: richard kappler <richkapp...@gmail.com>
Date: Sun, 22 Jul 2012 12:58:32 -0400
Local: Sun, Jul 22 2012 12:58 pm
Subject: Re: cadr vs cdr in describe-location
Craig, Mauricio, your explanations illustrated it beautifully, Now I
regards, Richard
On Sun, Jul 22, 2012 at 12:50 PM, Mauricio <maufd...@gmail.com> wrote:
-- > About your question regarding using cdr instead of cadr since there are > only two elements in the list, that is not quite the way it works, you have > to remember that a list is just a bunch of cons cell, the first (car) has > an element and the second (cdr) points to the car of the next cons cell, > the last cdr in the last cons in the list point to nil, and that is what > tells lisp it has reached the end of the list. > When you do cadr, you get the element which is in the first element of the
> To illustrate better just evaluate the following two lines in your repl.
> [1]> (cdr '(1 '(1 3 4)))
> The above is directly copied from my CLISP repl. As you can see the
> Also if you want shorthand for the second element in this case you can use
> [3]> (second '(1 '(1 3 4)))
> Hope I understood your question, and if so that my answer was clear.
> El sábado, 21 de julio de 2012 10:39:29 UTC-6, richard kappler escribió:
>> Some questions brought up by the text game in ch 5, particularly the
>> (defun describe-location (location nodes)
>> As I understand it, what's happening is we're defining a function named
>> 1. I think I get the read vs evaluate bit, but it's rather tenuous. Am
>> 2. cadr is the same as (car (cdr ()) which is the same as from the rest
>> 3. Do we use cadr because its just less typing (more elegant and
>> 4. Why not just use cdr since, in this case anyway, we know there are
>> regards, Richard
"Treat all disasters as if they were trivialities but never treat a triviality as if it were a disaster." -- *Quentin Crisp<http://www.quotationspage.com/quotes/Quentin_Crisp> * You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||