mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Add union
.
This commit is contained in:
parent
3f7e74e3cb
commit
d806e7407a
@ -7,6 +7,7 @@ module OrderedMap (
|
||||
, OrderedMap.lookup
|
||||
, size
|
||||
, empty
|
||||
, union
|
||||
) where
|
||||
|
||||
data OrderedMap key value = OrderedMap { toList :: [(key, value)] }
|
||||
@ -33,3 +34,7 @@ size = length . toList
|
||||
|
||||
empty :: OrderedMap key value
|
||||
empty = OrderedMap []
|
||||
|
||||
union :: Eq key => OrderedMap key value -> OrderedMap key value -> OrderedMap key value
|
||||
union (OrderedMap a) (OrderedMap b) = OrderedMap $ a ++ filter ((`elem` extant) . fst) b
|
||||
where extant = fst <$> a
|
||||
|
Loading…
Reference in New Issue
Block a user