File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,8 @@ unionBy eq xs ys = xs <> foldl (flip (deleteBy eq)) (nubBy eq ys) xs
580
580
581
581
-- | Delete the first element of an array which is equal to the specified value,
582
582
-- | creating a new array.
583
+ -- |
584
+ -- | Running time: `O(n)`
583
585
delete :: forall a . Eq a => a -> Array a -> Array a
584
586
delete = deleteBy eq
585
587
@@ -592,10 +594,11 @@ deleteBy eq x ys = maybe ys (\i -> unsafePartial $ fromJust (deleteAt i ys)) (fi
592
594
593
595
-- | Delete the first occurrence of each element in the second array from the
594
596
-- | first array, creating a new array.
597
+ -- |
598
+ -- | Running time: `O(n*m)`, where n is the length of the first array, and m is
599
+ -- | the length of the second.
595
600
difference :: forall a . Eq a => Array a -> Array a -> Array a
596
- difference xs ys
597
- | null xs = []
598
- | otherwise = uncons' (const xs) (\z zs -> delete z xs \\ zs) ys
601
+ difference = foldr delete
599
602
600
603
infix 5 difference as \\
601
604
You can’t perform that action at this time.
0 commit comments