@@ -686,17 +686,17 @@ nub = nubBy compare
686
686
-- | Running time: `O(n log n)`
687
687
nubBy :: forall a . (a -> a -> Ordering ) -> List a -> List a
688
688
nubBy p =
689
- -- Add indices so we can recover original order after deduplicating.
690
- addIndexReverse
691
- -- Sort by original values to cluster duplicates.
692
- >>> sortBy (p `on` snd)
693
- -- Removing neighboring duplicates.
694
- >>> nubByAdjacentReverse (\a b -> (p `on` snd) a b == EQ )
689
+ -- Discard indices, just keep original values.
690
+ mapReverse snd
695
691
-- Sort by index to recover original order.
696
692
-- Use `flip` to sort in reverse order in anticipation of final `mapReverse`.
697
- >>> sortBy (flip compare `on` fst)
698
- -- Discard indices, just keep original values.
699
- >>> mapReverse snd
693
+ <<< sortBy (flip compare `on` fst)
694
+ -- Removing neighboring duplicates.
695
+ <<< nubByAdjacentReverse (\a b -> (p `on` snd) a b == EQ )
696
+ -- Sort by original values to cluster duplicates.
697
+ <<< sortBy (p `on` snd)
698
+ -- Add indices so we can recover original order after deduplicating.
699
+ <<< addIndexReverse
700
700
701
701
-- | Remove duplicate elements from a list.
702
702
-- | Keeps the first occurrence of each element in the input list,
@@ -871,7 +871,7 @@ mapReverse f = go Nil
871
871
-- | Equivalent to:
872
872
-- |
873
873
-- | ```purescript
874
- -- | mapWithIndex Tuple >>> reverse
874
+ -- | reverse <<< mapWithIndex Tuple
875
875
-- | ```
876
876
-- |
877
877
-- | Running time: `O(n)`
0 commit comments