projects
/
haskell-directory.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bd56433
)
add Data.Set.notMember and Data.Map.notMember
author
John Meacham
<john@repetae.net>
Thu, 9 Mar 2006 19:18:06 +0000
(19:18 +0000)
committer
John Meacham
<john@repetae.net>
Thu, 9 Mar 2006 19:18:06 +0000
(19:18 +0000)
Data/Map.hs
patch
|
blob
|
history
Data/Set.hs
patch
|
blob
|
history
diff --git
a/Data/Map.hs
b/Data/Map.hs
index
24d8d2d
..
7124cd3
100644
(file)
--- a/
Data/Map.hs
+++ b/
Data/Map.hs
@@
-44,6
+44,7
@@
module Data.Map (
, null
, size
, member
, null
, size
, member
+ , notMember
, lookup
, findWithDefault
, lookup
, findWithDefault
@@
-272,6
+273,10
@@
member k m
Nothing -> False
Just x -> True
Nothing -> False
Just x -> True
+-- | /O(log n)/. Is the key not a member of the map?
+notMember :: Ord k => k -> Map k a -> Bool
+notMember k m = not $ Data.Map.member k m
+
-- | /O(log n)/. Find the value at a key.
-- Calls 'error' when the element can not be found.
find :: Ord k => k -> Map k a -> a
-- | /O(log n)/. Find the value at a key.
-- Calls 'error' when the element can not be found.
find :: Ord k => k -> Map k a -> a
diff --git
a/Data/Set.hs
b/Data/Set.hs
index
13dff75
..
9eb30a4
100644
(file)
--- a/
Data/Set.hs
+++ b/
Data/Set.hs
@@
-43,6
+43,7
@@
module Data.Set (
, null
, size
, member
, null
, size
, member
+ , notMember
, isSubsetOf
, isProperSubsetOf
, isSubsetOf
, isProperSubsetOf
@@
-203,6
+204,11
@@
member x t
GT -> member x r
EQ -> True
GT -> member x r
EQ -> True
+-- | /O(log n)/. Is the element not in the set?
+notMember :: Ord a => a -> Set a -> Bool
+notMember x t = not $ Data.Set.member x t
+
+
{--------------------------------------------------------------------
Construction
--------------------------------------------------------------------}
{--------------------------------------------------------------------
Construction
--------------------------------------------------------------------}