Last active
August 29, 2015 14:13
-
-
Save vishesh/2c2ead9db81c8c197ecf 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
; Purely functional implementation of Set data structure | |
(define set-init | |
(lambda (x) #false)) | |
(define (set-add set x) | |
(lambda (y) | |
(if (= x y) | |
#true | |
(set y)))) | |
(define (set-union set1 set2) | |
(lambda (y) | |
(or (set1 y) (set2 y)))) | |
(define (set-intersect set1 set2) | |
(lambda (y) | |
(and (set1 y) (set2 y)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment