list functions:: car, cdr, car

Discussion in 'AutoCAD' started by kzalec, Oct 14, 2004.

  1. kzalec

    kzalec Guest

    In the AutoLISP programming language, I would like to know the origination of the list functions named "car", "cdr" and "car". In other words, are these acronyms for something? What does "car" stand for? I know what it does. I'm just curious about where these terms came from.
     
    kzalec, Oct 14, 2004
    #1
  2. kzalec

    kzalec Guest

    Typo: I meant "cadr" in the previous message. I just want to know the origins of these list functions (car, cdr, and cadr).
     
    kzalec, Oct 14, 2004
    #2
  3. kzalec

    Doug Broad Guest

    CAR = Contents of the Address Register
    CDR = Contents of the Decrement Register.

    CADR = (CAR(CDR LST))

    Read about the origins of LISP language.


    functions named "car", "cdr" and "car". In other words, are these acronyms for something?
    What does "car" stand for? I know what it does. I'm just curious about where these terms
    came from.
     
    Doug Broad, Oct 14, 2004
    #3
  4. kzalec

    randy benson Guest

    I'm not being 'anti-semantic', here, just curious -
    I remembered it slightly differently, then did a google search and came up with
    something very slightly different from yours or mine:

    I thought it was

    CAR = Contents of the Address Register
    CDR = Contents of the DecrementED Register

    which implied (to me, not knowing any better) the use and re-use of a single
    register and the stack...

    but according to Steve Russell, who apparently was there, "I wrote the first
    implementation of a LISP interpreter on the IBM 704 at MIT in early in 1959. I
    hand-compiled John McCarthy's "Universal LISP Function". The 704 family (704,
    709, 7090) had "Address" and "Decrement" fields that were 15 bits long in some
    of the looping instructions. There were also special load and store instructions
    that moved these 15-bit addresses between memory and the index registers ( 3 on
    the 704, 7 on the others )

    We had devised a representation for list structure that took advantage of these
    instructions. Because of an unfortunate temporary lapse of inspiration, we
    couldn't think of any other names for the 2 pointers in a list node than
    "address" and "decrement", so we called the functions CAR for "Contents of
    Address of Register" and CDR for "Contents of Decrement of Register".

    After several months and giving a few classes in LISP, we realized that "first"
    and "rest" were better names, and we (John McCarthy, I and some of the rest of
    the AI Project) tried to get people to use them instead. Alas, it was too late!
    We couldn't make it stick at all. So we have CAR and CDR."
    <clipped from alt.folklore.computers via google.>

    I think it just means 'pointer to beginning of first item in a particular
    register' and 'pointer to beginning of the rest'. I'm usually wrong though.
     
    randy benson, Oct 15, 2004
    #4
  5. kzalec

    Doug Broad Guest

    Luis,
    And also to you. Have a nice weekend.

    Regards,
    Doug
     
    Doug Broad, Oct 15, 2004
    #5
  6. kzalec

    kzalec Guest

    Thanks to all who replied. I found the same results yesterday from a fellow programmer. It makes sense since "address" (car) returns the first element in the list and "decrement" (cdr) returns a list with the first element removed. And "cadr" performs two operations, cdr and car, to return the second element of the list. (The cdr function removes the first element, and the car function returns the first element of the new list.)
     
    kzalec, Oct 15, 2004
    #6
  7. kzalec

    Dan Allen Guest

    Dan Allen, Oct 16, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.