Search results

nubBy :: forall a. (a -> a -> Ordering) -> Array a -> Array a

Remove the duplicates from an array, where element equality is determined by the specified ordering, creating a new array.

nubBy compare [1, 3, 4, 2, 2, 1] == [1, 3, 4, 2]
P purescript-arrays M Data.Array
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyArray a -> NonEmptyArray a
P purescript-arrays M Data.Array.NonEmpty
nubBy :: forall a. (a -> a -> Ordering) -> List a -> List a

Remove duplicate elements from a list based on the provided comparison function. Keeps the first occurrence of each element in the input list, in the same order they appear in the input list.

nubBy (compare `on` Array.length) ([1]:[2]:[3,4]:Nil) == [1]:[3,4]:Nil

Running time: O(n log n)

P purescript-lists M Data.List
nubBy :: forall a. (a -> a -> Ordering) -> List a -> List a

Remove duplicate elements from a list based on the provided comparison function. Keeps the first occurrence of each element in the input list, in the same order they appear in the input list.

Running time: O(n log n)

P purescript-lists M Data.List.Lazy
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyList a -> NonEmptyList a
P purescript-lists M Data.List.NonEmpty
nubBy :: forall a. (a -> a -> Ordering) -> ArrayView a -> ArrayView a
P purescript-array-views M Data.ArrayView
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyArrayView a -> NonEmptyArrayView a
P purescript-array-views M Data.ArrayView.NonEmpty
nubBy :: forall a. (a -> a -> Boolean) -> List a -> List a

Remove the duplicates from a list, where element equality is determined by the specified equivalence relation, creating a new list.

P purescript-rrb-list M RRBList
nubBy :: forall a. (a -> a -> Ordering) -> SortedArray a -> SortedArray a

Creates a new array that contains no duplicates by using the specified equivalence relation.

P purescript-sorted-arrays M Data.SortedArray
nubByEq :: forall a. (a -> a -> Boolean) -> Array a -> Array a

Remove the duplicates from an array, where element equality is determined by the specified equivalence relation, creating a new array.

This less efficient version of nubBy only requires an equivalence relation.

mod3eq a b = a `mod` 3 == b `mod` 3
nubByEq mod3eq [1, 3, 4, 5, 6] = [1, 3, 5]
P purescript-arrays M Data.Array
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyArray a -> NonEmptyArray a
P purescript-arrays M Data.Array.NonEmpty
nubByEq :: forall a. (a -> a -> Boolean) -> List a -> List a

Remove duplicate elements from a list, using the provided equivalence function. Keeps the first occurrence of each element in the input list, in the same order they appear in the input list. This less efficient version of nubBy only requires an equivalence function, rather than an ordering function.

mod3eq = eq `on` \n -> mod n 3
nubByEq mod3eq 1:3:4:5:6:Nil == 1:3:5:Nil

Running time: O(n^2)

P purescript-lists M Data.List
nubByEq :: forall a. (a -> a -> Boolean) -> List a -> List a

Remove duplicate elements from a list, using the specified function to determine equality of elements.

Running time: O(n^2)

P purescript-lists M Data.List.Lazy
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList a
P purescript-lists M Data.List.NonEmpty
nubByEq :: forall a. (a -> a -> Boolean) -> ArrayView a -> ArrayView a
P purescript-array-views M Data.ArrayView
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyArrayView a -> NonEmptyArrayView a
P purescript-array-views M Data.ArrayView.NonEmpty

No further results.