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]
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyArray a -> NonEmptyArray a
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)
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)
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyList a -> NonEmptyList a
nubBy :: forall a. (a -> a -> Ordering) -> ArrayView a -> ArrayView a
nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyArrayView a -> NonEmptyArrayView a
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.
nubBy :: forall a. (a -> a -> Ordering) -> SortedArray a -> SortedArray a
Creates a new array that contains no duplicates by using the specified equivalence relation.
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]
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyArray a -> NonEmptyArray a
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)
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)
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList a
nubByEq :: forall a. (a -> a -> Boolean) -> ArrayView a -> ArrayView a
nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyArrayView a -> NonEmptyArrayView a
No further results.