Created
September 12, 2019 18:55
-
-
Save Boarders/99db42ead88d7252ff8555dd1fd35323 to your computer and use it in GitHub Desktop.
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
#lang scheme | |
;; church encoded zero | |
(define c-zero | |
(lambda (f x) x)) | |
;; church encoded one | |
(define (add-1 cn) | |
(lambda (f x) (f (cn f x)))) | |
;; addition of chruch numerals | |
(define (c-add cn cm) | |
(lambda (f x) (cn f (cm f x)))) | |
;; mulitplication of church numerals | |
(define (c-mult cn cm) | |
(lambda (f x) (cn (lambda (x) (cm f x)) x))) | |
;; exponential of chrurch numerals | |
(define (c-exp cn cm) | |
(lambda (f x) (error "to do")) | |
;; convert from church numeral to literal | |
(define (to-Nat cn) | |
(cn add1 0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment