So, in Lispy languages you can access the head and tail of a list with `car` and `cdr` (insert historical sidebar here about what these names originally meant). But maybe you want the second element of a list -- that is, the head of the tail of the list. Or maybe the list's elements are themselves lists and you want the tail of the head. And so on. For this reason, there are pair accessor shorthands: (caar ls) is shorthand for (car (car ls)), (cdar ls) is shorthand for (cdr (car ls)), and so on.

In the Racket docs (https://docs.racket-lang.org/reference/pairs.html#(part._.Pair_.Accessor_.Shorthands)), these pair accessor shorthands go all the way up to four levels of nesting: caar, cadr, cdar, cddr, caaar, caadr, cadar, caddr, cdaar, cdadr, cddar, cdddr, caaaar, caaadr, caadar, caaddr, cadaar, cadadr, caddar, cadddr, cdaaar, cdaadr, cdadar, cdaddr, cddaar, cddadr, cdddar, cddddr.

BUT WHY STOP THERE?!? Why can't I write `caaaaaaaaar` and have it just work?

4.10 Pairs and Lists

@lindsey This is so clearly readable.
@MartinEscardo @lindsey Can this be mixed with regex somehow?
@dabeaz @MartinEscardo I personally find functions like `cdadr` to be charming and delightful. At the same time, I would never, ever want to subject anyone else to them. They are truly blursed.

@lindsey writes "At the same time, I would never, ever want to subject anyone else to them."

Sincere thanks for that!

@dabeaz

@lindsey @dabeaz @MartinEscardo I wish someone had used the word "blursed" when I was forced to learn those functions exactly 50 years ago. It would have made me not feel as stupid for being so confused about them. (This was for OG Scheme.)
@lindsey @MartinEscardo I remember taking a SICP group out for a coffee break (when I still taught in person) and we were all standing in line talking about some car-this, cdr-that, cadr thing. We got a lot of weird looks for that.

@dabeaz writes " We got a lot of weird looks for that."

This reminds of a story from the last millennium.

I was in the queue with various people for lunch, at Kings Buildings in Ediburgh, including Alex Simpson, John Longley, Samson Abramsky and Gordon Plotkin, and I was saying verbally something about "continuous functions from X to two".

Then somebody asked "what is 'two'". And I said "one plus one", which was clear to them (they wanted to know whether I was talking about the Sierpinski space or the two-point discrete space).

But we got, repeating your words, "weird looks for that" from everybody else in the queue.

@lindsey

@MartinEscardo @dabeaz @lindsey That story in turn reminded me of the time I was explaining Conway's field structure on the natural numbers to a friend, but I only knew a very basic definition. I knew the addition was "nim-addition": write the numbers in base 2 and add the corresponding digits mod 2 without carries. And I knew that the product of two natural numbers is the smallest it could be, that is the smallest number for which you can't get a contradiction by assuming that's the product and using the field axioms. This is a notoriously impractical definition of multiplication. We were walking and talking, trying to build out the multiplication table one product at a time. It tools us a long time to figure out 2×4. We proved it couldn't be 0, it couldn't be 1, it couldn't be 2, etc. Just as we were arriving at a taco stand, we figured out that in this field structure 2×4=8. We got funny looks from the taqueria and the people eating tacos for being so damn excited about 2×4=8.
@MartinEscardo @dabeaz @lindsey Jesus Christ, that must have been something like 25 years ago. 😱