Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,12 @@ nubBy comp xs = case head indexedAndSorted of
-- | ```
-- |
nubByEq :: forall a. (a -> a -> Boolean) -> Array a -> Array a
nubByEq eq xs =
case uncons xs of
Just o -> o.head : nubByEq eq (filter (\y -> not (o.head `eq` y)) o.tail)
Nothing -> []
nubByEq eq xs = ST.run do
arr <- STA.empty
ST.foreach xs \x -> do
e <- not <<< Exports.any (_ `eq` x) <$> (STA.unsafeFreeze arr)
when e $ void $ STA.push x arr
STA.unsafeFreeze arr

-- | Calculate the union of two arrays. Note that duplicates in the first array
-- | are preserved while duplicates in the second array are removed.
Expand Down