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 @@ -573,6 +573,8 @@ unionBy eq xs ys = xs <> foldl (flip (deleteBy eq)) (nubBy eq ys) xs
573573
574574-- | Delete the first element of an array which is equal to the specified value,
575575-- | creating a new array.
576+ -- |
577+ -- | Running time: `O(n)`
576578delete :: forall a . Eq a => a -> Array a -> Array a
577579delete = deleteBy eq
578580
@@ -585,10 +587,11 @@ deleteBy eq x ys = maybe ys (\i -> unsafePartial $ fromJust (deleteAt i ys)) (fi
585587
586588-- | Delete the first occurrence of each element in the second array from the
587589-- | first array, creating a new array.
590+ -- |
591+ -- | Running time: `O(n*m)`, where n is the length of the first array, and m is
592+ -- | the length of the second.
588593difference :: forall a . Eq a => Array a -> Array a -> Array a
589- difference xs ys
590- | null xs = []
591- | otherwise = uncons' (const xs) (\z zs -> delete z xs \\ zs) ys
594+ difference = foldr delete
592595
593596infix 5 difference as \\
594597
You can’t perform that action at this time.
0 commit comments