diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-30 05:41:44 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-30 05:41:44 +0400 |
commit | 0b05b30661eb9e5c60ded740f79603bbb0d46a19 (patch) | |
tree | 36e3c54ee927e594ee46b1834f278bccef4abf3c | |
parent | e7cf4c0f1dff0eaa24aa5f8dfc2762192899f672 (diff) |
Implement union function
-rw-r--r-- | src/Data/BEncode/BDict.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Data/BEncode/BDict.hs b/src/Data/BEncode/BDict.hs index 925027b..8ef6d20 100644 --- a/src/Data/BEncode/BDict.hs +++ b/src/Data/BEncode/BDict.hs | |||
@@ -89,7 +89,11 @@ lookup x = go | |||
89 | {-# INLINE lookup #-} | 89 | {-# INLINE lookup #-} |
90 | 90 | ||
91 | union :: BDictMap a -> BDictMap a -> BDictMap a | 91 | union :: BDictMap a -> BDictMap a -> BDictMap a |
92 | union = undefined | 92 | union Nil xs = xs |
93 | union xs Nil = xs | ||
94 | union bd @ (Cons k v xs) bd' @ (Cons k' v' xs') | ||
95 | | k < k' = Cons k v (union xs bd') | ||
96 | | otherwise = Cons k' v' (union bd xs') | ||
93 | 97 | ||
94 | map :: (a -> b) -> BDictMap a -> BDictMap b | 98 | map :: (a -> b) -> BDictMap a -> BDictMap b |
95 | map f = go | 99 | map f = go |