Created
August 2, 2015 17:40
-
-
Save tim-br/c22ff689c865f11cc67c to your computer and use it in GitHub Desktop.
set functions from sicp for haskell
This file contains hidden or 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
intersection_set _ [] = [] | |
intersection_set [] _ = [] | |
intersection_set (x:xs) ys | |
| element_of_set x ys = x : intersection_set xs ys | |
| otherwise = intersection_set xs ys | |
element_of_set _ [] = False | |
element_of_set x (y:ys) | |
| x == y = True | |
| otherwise = element_of_set x ys | |
adjoin_set x ys | |
| element_of_set x ys = ys | |
| otherwise = x : ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment