(caar x) == (car (car x))
(cddar x) == (cdr (cdr (car (x)))
Something which you can't do with first and rest. This has (AFAIK) always been one of the arguments for car and cdr. (caar x) == (car (car x))
(cddar x) == (cdr (cdr (car (x)))
Something which you can't do with first and rest. This has (AFAIK) always been one of the arguments for car and cdr.http://www.nongnu.org/txr/txr-manpage.html#N-03E5CED9
The code for them is generated textually: http://www.kylheku.com/cgit/txr/tree/gencadr.txr
Compare:
(caadar x) => (car (car (car (cdr (car x)))))
Saves parens too.As a general rule, I assume that I read most lines of the code not when I'm writing it, nor fixing a bug, but while I'm trying to locate a bug of unknown location. The complexity or trickiness of a function that you are actively modifying can be pretty high and you'll still grasp it. But a function not even involved with a problem needs to be even more legible if you don't want to repeatedly waste time contemplating it to determine if you should move on.
There are first, etc... accessors (other Lisps might define them too, it is so easy to implement). People are encouraged to use them, especially for lists, and are even encouraged to not use them but prefer objects with named slots.
The general advice is to reserve C..R functions for trees, but this is actually rarely needed, especially when using pattern matching.