Quantify List, Set, Dict or a single value according to a predicate
Quantify a list according to a predicate.
isEven : Int -> Bool
isEven number =
modBy 2 number == 0
Quantify.list isEven [1,3,5,7]
--> None
Quantify.list isEven [0,1,2,3]
--> Some
Quantify.list isEven [0,2,4,6]
--> All
Quantify.list isEven []
--> NoneQuantify a set according to a predicate.
import Set
isEven : Int -> Bool
isEven number =
modBy 2 number == 0
Quantify.set isEven (Set.fromList [1,3,5,7])
--> None
Quantify.set isEven (Set.fromList [0,1,2,3])
--> Some
Quantify.set isEven (Set.fromList [0,2,4,6])
--> All
Quantify.set isEven Set.empty
--> NoneQuantify a dict according to a predicate. The predicate gets both the key and the value.
import Dict
isEven : Int -> Bool
isEven number =
modBy 2 number == 0
Quantify.dict (\key value -> isEven value) (Dict.fromList [(0,1),(1,3),(2,5),(3,7)])
--> None
Quantify.dict (\key value -> isEven value) (Dict.fromList [(0,0),(1,1),(2,2),(3,3)])
--> Some
Quantify.dict (\key value -> isEven value) (Dict.fromList [(0,0),(1,2),(2,4),(3,6)])
--> All
Quantify.dict (\key value -> isEven value) Dict.empty
--> NoneQuantify a single value according to a predicate.
isEven : Int -> Bool
isEven number =
modBy 2 number == 0
Quantify.single isEven 1
--> None
Quantify.single isEven 0
--> AllQuantify a Bool value according to a predicate.
Quantify.fromBool True
--> All
Quantify.fromBool False
--> None
Quantifier type describes the result of the quantification.