:: Ord a => [a] -> [a] -package:list-t -package:imports -package:containers -package:amazonka-core -package:base -is:exact -package:ghc -package:base-prelude -package:errors -package:incipit-base -package:Cabal-syntax -package:hedgehog -package:integration
Like
nub, but has
O(n log n) complexity instead of
O(n^2). Code for
ordNub and
listUnion taken
from Niklas Hambüchen's
ordnub package.
A right-biased version of
ordNub.
Example:
>>> ordNub [1,2,1] :: [Int]
[1,2]
>>> ordNubRight [1,2,1] :: [Int]
[2,1]
O(n log n). The
nubOrd function removes duplicate
elements from a list. In particular, it keeps only the first
occurrence of each element. Unlike the standard
nub operator,
this version requires an
Ord instance and consequently runs
asymptotically faster.
nubOrd "this is a test" == "this ae"
nubOrd (take 4 ("this" ++ undefined)) == "this"
\xs -> nubOrd xs == nub xs
O(n log n). The
nubSort function sorts and removes
duplicate elements from a list. In particular, it keeps only the first
occurrence of each element.
nubSort "this is a test" == " aehist"
\xs -> nubSort xs == nub (sort xs)
Equivalent to
drop 1, but likely to be faster and a single
lexeme.
drop1 "" == ""
drop1 "test" == "est"
\xs -> drop 1 xs == drop1 xs
Equivalent to
dropEnd 1, but likely to be faster and a single
lexeme.
dropEnd1 "" == ""
dropEnd1 "test" == "tes"
\xs -> dropEnd 1 xs == dropEnd1 xs
Identical to
tail, namely that fails on an empty list. Useful
to avoid the
x-partial warning introduced in GHC 9.8.
tailErr [] = error "Prelude.tail: empty list"
tailErr [1,2,3] = [2,3]
tailSafe [] = []
tailSafe [1,3,4] = [3,4]
The
nub function which removes duplicate elements from a
vector.
Removes duplicate elements from a list, keeping only the first
occurrence. This is asymptotically faster than using
nub from
Data.List.
>>> ordNub [3,2,1,3,2,1]
[3,2,1]
Generalized version of
mask_.
O(n) Convert a vector to a list.
Take a parser that may consume input, and on failure, go back to where
we started and fail as if we didn't consume input.