File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1727,6 +1727,15 @@ powerSet xs0 = insertMin empty (foldr' step Tip xs0) where
17271727--
17281728-- @since 0.5.11
17291729cartesianProduct :: Set a -> Set b -> Set (a , b )
1730+ -- We don't know if this implementation (slightly modified from one
1731+ -- that Edward Kmett hacked together) is optimal. It would be interesting
1732+ -- to find out. TODO: try to get some clue about the big-O performance
1733+ -- so we can advise users.
1734+
1735+ -- When the second argument has at most one element, we can be a little
1736+ -- clever.
1737+ cartesianProduct ! _as Tip = Tip
1738+ cartesianProduct as (Bin 1 b _ _) = mapMonotonic (flip (,) b) as
17301739cartesianProduct as bs =
17311740 getMergeSet $ foldMap (\ a -> MergeSet $ mapMonotonic ((,) a) bs) as
17321741
You can’t perform that action at this time.
0 commit comments