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
1727
1727
--
1728
1728
-- @since 0.5.11
1729
1729
cartesianProduct :: 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
1730
1739
cartesianProduct as bs =
1731
1740
getMergeSet $ foldMap (\ a -> MergeSet $ mapMonotonic ((,) a) bs) as
1732
1741
You can’t perform that action at this time.
0 commit comments