What does "my other car is a cdr" mean?

LispConsCdr

Lisp Problem Overview


Can anyone well versed in lisp explain this joke to me? I've done some reading on functional programming languages and know that CAR/CDR mean Contents of Address/Decrement Register but I still don't really understand the humour.

Lisp Solutions


Solution 1 - Lisp

In Lisp, a linked list element is called a CONS. It is a data structure with two elements, called the CAR and the CDR for historical reasons. (Some Common Lisp programmers prefer to refer to them using the FIRST and REST functions, while others like CAR and CDR because they fit well with the precomposed versions such as (CADR x) ≡ (CAR (CDR x)).

The joke is a parody of the bumper stickers you sometimes see on beat-up old cars saying "My other car is a Porsche/BMW/etc."

My response to this joke has always been "My other CAR is a CADR. CDR isn't a CAR at all."

Solution 2 - Lisp

Yes, definitely a geek joke.

The names come from the IBM 704, but that's not the joke.

The joke is (bad) pun on "my other car is a ___." But the in-joke is about recursion.

When you loop/manipulate/select/invoke/more in lisp you use a combination of car (the first element in the list) and cdr (the rest of the list) to juggle functions.

So you've got a car, but your other car is your cdr because you can always get a car from a cdr since the cdr is always (in recursion) more elements. Get it? Laugh yet?

You'll probably have to learn lisp to actually chuckle a bit, or not. Of course, by then, you'll probably find yourself chuckling randomly for no apparent reason because:

Lisp makes you loopy.

Solution 3 - Lisp

//Coming from Scheme
Scheme has very few data structures, one of them is a tuple: '(first . second). In this case, car is the first element, and cdr is the second. This construct can be extended to create lists, trees, and other structures.
The joke isn't very funny.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCaptainCaseyView Question on Stackoverflow
Solution 1 - LispPeter S. HouselView Answer on Stackoverflow
Solution 2 - LispzenView Answer on Stackoverflow
Solution 3 - LispKobiView Answer on Stackoverflow