Created
October 30, 2019 14:58
-
-
Save chelseatroy/36bd9888e45ec1afe5a1559fb12cfb18 to your computer and use it in GitHub Desktop.
Representing Primitives as Procedures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 2.6: Representing a primitive (numbers) as procedures | |
(define zero (lambda (f) (lambda (x) x))) | |
(define (add-1 n) | |
(lambda (f) (lambda (x) (f ((n f) x))))) | |
(define (inc x) (+ 1 x)) | |
(define one (lambda (f x) (f x))) | |
(define two (lambda (f x) (f (f x)))) | |
(define three (lambda (f x) (f (f (f x))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment