Created
March 18, 2019 22:41
-
-
Save Frazi1/e96a5d51202c7dbcfea7154d2289e2fb to your computer and use it in GitHub Desktop.
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
data Set a = Set (a->Bool) | |
contains (Set a) x = a x | |
singletonSet x = Set(\y-> x==y) | |
union a b = Set(\x -> contains a x || contains b x) | |
intersect a b = Set(\x -> contains a x && contains b x) | |
forall s p = | |
let | |
iter i | |
| i < 1000 = (not (contains s i) || p i) && (iter (i+1)) | |
| otherwise = True | |
in iter (-1000) | |
exists s p = forall s p || not (forall s (\x-> not (p x))) | |
map s t = | |
let | |
iter i | |
| i < 1000 = let | |
| otherwise = True | |
in iter (-1000) | |
main = do | |
putStrLn "Hello" | |
putStrLn "World" | |
--let un = union (singletonSet 1) (singletonSet 2) | |
--print (contains un 2) | |
--print (contains un 3) | |
--let intersected = intersect un (singletonSet 2) | |
--print (contains intersected 1) | |
--print (contains intersected 2) | |
let testS = union (singletonSet 10) (singletonSet 20) | |
print (forall testS (\x -> x < 20 || x > 10)) | |
print (exists testS (\x -> x > 20)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment