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
580580
581581-- | Delete the first element of an array which is equal to the specified value,
582582-- | creating a new array.
583+ -- |
584+ -- | Running time: `O(n)`
583585delete :: forall a . Eq a => a -> Array a -> Array a
584586delete = deleteBy eq
585587
@@ -592,10 +594,11 @@ deleteBy eq x ys = maybe ys (\i -> unsafePartial $ fromJust (deleteAt i ys)) (fi
592594
593595-- | Delete the first occurrence of each element in the second array from the
594596-- | 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.
595600difference :: 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
599602
600603infix 5 difference as \\
601604
You can’t perform that action at this time.
0 commit comments