on master help sign in
Mess with style, perf, and docs
1edc02fEvan Czaplicki
libraries/Dict.elm+6−10
@@ -353,20 +353,16 @@ fromList : [(comparable,v)] -> Dict comparable v
353fromList assocs = List.foldl (\(k,v) d -> insert k v d) empty assocs
353fromList assocs = List.foldl (\(k,v) d -> insert k v d) empty assocs
354
354
355{-| Keep a key-value pair when it satisfies a predicate. -}
355{-| Keep a key-value pair when it satisfies a predicate. -}
356−filter : (comparable -> v -> Bool)
356+filter : (comparable -> v -> Bool) -> Dict comparable v -> Dict comparable v
357− -> Dict comparable v
358− -> Dict comparable v
359−filter p =
357+filter p dict =
360 let add k v t = if p k v then insert k v t else t
358 let add k v t = if p k v then insert k v t else t
361− in foldl add empty
359+ in foldl add empty dict
362
360
363{-| Partition the Dict according to a predicate. The first Dict contains all
361{-| Partition the Dict according to a predicate. The first Dict contains all
364key-value pairs which satisfy it; the second contains the rest. -}
362key-value pairs which satisfy it; the second contains the rest. -}
365−partition : (comparable -> v -> Bool)
366− -> Dict comparable v
367− -> (Dict comparable v, Dict comparable v)
363+partition : (comparable -> v -> Bool) -> Dict comparable v -> (Dict comparable v, Dict comparable v)
368−partition p =
364+partition p dict =
369 let add k v (t1, t2) = if p k v
365 let add k v (t1, t2) = if p k v
370 then (insert k v t1, t2)
366 then (insert k v t1, t2)
371 else (t1, insert k v t2)
367 else (t1, insert k v t2)
372− in foldl add (empty, empty)
368+ in foldl add (empty, empty) dict
libraries/Set.elm+4−6
@@ -26,7 +26,7 @@ Insert, remove, and query operations all take *O(log n)* time.
26@docs toList, fromList
26@docs toList, fromList
27
27
28# Transform
28# Transform
29−@docs map, foldl, foldr
29+@docs map, foldl, foldr, filter, partition
30
30
31-}
31-}
32
32
@@ -92,11 +92,9 @@ map f s = fromList (List.map f (toList s))
92
92
93{-| Create a new set consisting only of elements which satisfy a predicate. -}
93{-| Create a new set consisting only of elements which satisfy a predicate. -}
94filter : (comparable -> Bool) -> Set comparable -> Set comparable
94filter : (comparable -> Bool) -> Set comparable -> Set comparable
95−filter p = Dict.filter (\k _ -> p k)
95+filter p set = Dict.filter (\k _ -> p k) set
96
96
97{-| Create two new sets; the first consisting of elements which satisfy a
97{-| Create two new sets; the first consisting of elements which satisfy a
98predicate, the second consisting of elements which do not. -}
98predicate, the second consisting of elements which do not. -}
99−partition : (comparable -> Bool)
100− -> Set comparable
101− -> (Set comparable, Set comparable)
99+partition : (comparable -> Bool) -> Set comparable -> (Set comparable, Set comparable)
102−partition p = Dict.partition (\k _ -> p k)
100+partition p set = Dict.partition (\k _ -> p k) set