This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ module Data.Map
99 toList ,
1010 fromList ,
1111 union ,
12+ unions ,
1213 map
1314 ) where
1415
@@ -85,6 +86,9 @@ fromList = foldl (\m (Tuple k v) -> insert k v m) empty
8586union :: forall k v . (P.Eq k , P.Ord k ) => Map k v -> Map k v -> Map k v
8687union m1 m2 = foldl (\m (Tuple k v) -> insert k v m) m2 (toList m1)
8788
89+ unions :: forall k v . (P.Ord k ) => [Map k v ] -> Map k v
90+ unions = foldl union empty
91+
8892map :: forall k v1 v2 . (P.Eq k , P.Ord k ) => (v1 -> v2 ) -> Map k v1 -> Map k v2
8993map _ Leaf = Leaf
9094map f (Branch b) = Branch (b { value = f b.value, left = map f b.left, right = map f b.right })
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ module Data.Set
77 delete ,
88 toList ,
99 fromList ,
10- union
10+ union ,
11+ unions
1112 ) where
1213
1314import qualified Prelude as P
@@ -69,3 +70,5 @@ fromList = foldl (\s a -> insert a s) empty
6970union :: forall a . (P.Eq a , P.Ord a ) => Set a -> Set a -> Set a
7071union s1 s2 = foldl (\s a -> insert a s) s2 (toList s1)
7172
73+ unions :: forall a . (P.Ord a ) => [Set a ] -> Set a
74+ unions = foldl union empty
You can’t perform that action at this time.
0 commit comments