Skip to content

Instantly share code, notes, and snippets.

@Frazi1
Created March 18, 2019 22:41
Show Gist options
  • Save Frazi1/e96a5d51202c7dbcfea7154d2289e2fb to your computer and use it in GitHub Desktop.
Save Frazi1/e96a5d51202c7dbcfea7154d2289e2fb to your computer and use it in GitHub Desktop.
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