projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
17de35d
)
Give an example of how intersection takes elements from the first set
author
Ian Lynagh
<igloo@earth.li>
Sat, 12 May 2007 16:02:53 +0000
(16:02 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Sat, 12 May 2007 16:02:53 +0000
(16:02 +0000)
Data/Set.hs
patch
|
blob
|
history
diff --git
a/Data/Set.hs
b/Data/Set.hs
index
9ec9e4c
..
04d0100
100644
(file)
--- a/
Data/Set.hs
+++ b/
Data/Set.hs
@@
-340,7
+340,16
@@
hedgeDiff cmplo cmphi t (Bin _ x l r)
Intersection
--------------------------------------------------------------------}
-- | /O(n+m)/. The intersection of two sets.
Intersection
--------------------------------------------------------------------}
-- | /O(n+m)/. The intersection of two sets.
--- Elements of the result come from the first set.
+-- Elements of the result come from the first set, so for example
+--
+-- > import qualified Data.Set as S
+-- > data AB = A | B deriving Show
+-- > instance Ord AB where compare _ _ = EQ
+-- > instance Eq AB where _ == _ = True
+-- > main = print (S.singleton A `S.intersection` S.singleton B,
+-- > S.singleton B `S.intersection` S.singleton A)
+--
+-- prints @(fromList [A],fromList [B])@.
intersection :: Ord a => Set a -> Set a -> Set a
intersection Tip t = Tip
intersection t Tip = Tip
intersection :: Ord a => Set a -> Set a -> Set a
intersection Tip t = Tip
intersection t Tip = Tip