Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antimatter15/02674d7e8b16cdf7aeaba52eaec47489 to your computer and use it in GitHub Desktop.
Save antimatter15/02674d7e8b16cdf7aeaba52eaec47489 to your computer and use it in GitHub Desktop.
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