We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d218f6f + 8e90603 commit 83c2148Copy full SHA for 83c2148
src/Data/Array.purs
@@ -926,10 +926,12 @@ nubBy comp xs = case head indexedAndSorted of
926
-- | ```
927
-- |
928
nubByEq :: forall a. (a -> a -> Boolean) -> Array a -> Array a
929
-nubByEq eq xs =
930
- case uncons xs of
931
- Just o -> o.head : nubByEq eq (filter (\y -> not (o.head `eq` y)) o.tail)
932
- Nothing -> []
+nubByEq eq xs = ST.run do
+ arr <- STA.empty
+ ST.foreach xs \x -> do
+ e <- not <<< Exports.any (_ `eq` x) <$> (STA.unsafeFreeze arr)
933
+ when e $ void $ STA.push x arr
934
+ STA.unsafeFreeze arr
935
936
-- | Calculate the union of two arrays. Note that duplicates in the first array
937
-- | are preserved while duplicates in the second array are removed.
0 commit comments