Skip to content

Instantly share code, notes, and snippets.

@ldcc
Last active May 23, 2019 11:05
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 ldcc/eb4e7053e64293aae51551c5a4f377a6 to your computer and use it in GitHub Desktop.
Save ldcc/eb4e7053e64293aae51551c5a4f377a6 to your computer and use it in GitHub Desktop.
cons combinators
(define (cons1 x y)
(λ (m) (m x y)))
(define (car1 z)
(z (λ (p q) p)))
(define (cdr1 z)
(z (λ (p q) q)))
(define (cons2 x y)
(λ (z)
(cond [(= z 'x) x]
[(= z 'y) y])))
(define (car2 l)
(l 'x))
(define (cdr2 l)
(l 'y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment