Tagged as challenge
Written on 2018-02-06
Most Lisps have combinations of
cdr built in, usually up
to four levels deep, e.g.,
cdaddr are built-ins
(lambda (x) (car (car (cdr (cdr x))))) ; and (lambda (x) (cdr (car (cdr (cdr x)))))
respectively. Implement a macro
(generate-cxr n) which generates the
definitions of all
cdr combinations up to
If your language doesn't support macros or dynamic definitions, write
a function of the same name which produces a list of all
combinations as anonymous functions.
Extra Credit: Implement this as efficiently as possible, using the least amount of space.