One of the great schisms in the Lisp community is if we should have car
and cdr
or first
and rest
. One of the benefits of the traditional car
and cdr
is that we can combine them to produce pronoucible functions like cdaddr
. How do Lisps that do not use car
and cdr
, such as Clojure, typically form combinations like this with first
and rest
? Is there any consensus?

- 1,868
- 1
- 9
- 38
-
2I am sorry but I don't see a schism, Clojure is more recent so it dropped a little historical bagage here and there but this is however a pretty minor detail – coredump Jan 31 '21 at 00:59
-
If there are lisps (I guess there is one) which only have `first` & `rest` they're making the treatment of conses as things out of which you can build structures which are not just lists as some secondary thing. As an example, an alist is a list (`first` / `rest`) of *pairs* (`car` / `cdr`), not a list of lists. (This doesn't make all the `cdaaaaddaddr` things more than a historical curiosity.) – Jan 31 '21 at 10:41
1 Answers
Clojure, at any rate, simply has no need for caddaadr and friends, because nobody builds data structures out of just cons cells. The language does have combinations of any two of first
and next
, named ffirst
, fnext
, nnext
, and nfirst
, which were added very early on I suppose because it was assumed we'd want something like cadr, but I never see them used in real life. Instead destructuring is used quite often.
On the rare occasions where you need to reach deeply into a structure built of nested sequences, destructuring often still produces readable code but also writing it out longhand is no great burden. It's also a good hint to you that maybe you should abstract thing a bit more rather than working with so many layers of primitive combinators directly.
-
@J.Mini The docs are all basically just like "Same as (x (y it))` - and the source is that (with some options to inline it) – cfrick Jan 30 '21 at 15:27
-
(a) It's really easy to find such documentation with Google, and (b) it is not at all enlightening. – amalloy Jan 30 '21 at 15:28
-
2
-
2@cfrick Good point. I suggest adding that as an answer, or editing it into mine. – amalloy Jan 30 '21 at 15:33