I see this a lot in examples I read in books and articles:
(caddr *something*)
Or the many variants of c***r commands.
It seems a bit ridiculous to me, when you can more clearly just pull things out with elt
:
(elt *something* 2)
But I don't see this technique used as much.
Is there a convention I don't understand that prefers the c***r functions?
elt
(andnth
) are random access functions. Most of the code that you'd write for list processing will be more concerned with, e.g., thefirst
andrest
of a list, not arbitrary elements. It's rare to seeelt
ornth
for lists because it's not used in much typical code. It's also not very common to seec[ad]+r
functions in typical code, because it's not typically the way we work with lists. Unfortunately, books and articles don't always exemplify typical code. – Kehr