Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
thing
= (list 1 2 3 4)
= (1 . (2 . (3 . (4 . nil))))
(car thing)
= 1
(cdr thing)
= (2 . (3 . (4 . nil)))
= cdr_thing
(cdr (cdr thing))
= (3 . (4 . nil))
= cdrcdr_thing
(cdr (cdr (cdr thing)))
= (4 . nil)
= cdrcdrcdr_thing
(define (car x) carmap[x])
(define (cdr x) cdrmap[x])
carmap = {
thing: 1
cdr_thing: 2
cdrcdr_thing: 3
cdrcdrcdr_thing: 4
}
cdrmap = {
thing: cdr_thing
cdr_thing: cdrcdr_thing
cdrcdr_thing: cdrcdrcdr_thing
cdrcdrcdr_thing: nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.