:: List a -> List a package:vector
O(1) Yield all but the last element without copying. The vector
may not be empty.
O(1) Yield all but the first element without copying. The
vector may not be empty.
O(1) Yield all but the last element without copying. The vector
may not be empty, but this is not checked.
O(1) Yield all but the first element without copying. The
vector may not be empty, but this is not checked.
O(n) Yield the argument, but force it not to retain any extra
memory, by copying it.
This is especially useful when dealing with slices. For example:
force (slice 0 2 <huge vector>)
Here, the slice retains a reference to the huge vector. Forcing it
creates a copy of just the elements that belong to the slice and
allows the huge vector to be garbage collected.
O(n) Convert between different vector types.
O(1) First element of a vector in a monad. See
indexM
for an explanation of why this is useful.
O(1) Last element of a vector in a monad. See
indexM for
an explanation of why this is useful.
O(1) First element in a monad, without checking for empty
vectors. See
indexM for an explanation of why this is useful.
O(1) Last element in a monad, without checking for empty
vectors. See
indexM for an explanation of why this is useful.
O(n) Drop repeated adjacent elements. The first element in each
group is returned.
Examples
>>> import qualified Data.Vector.Strict as V
>>> V.uniq $ V.fromList [1,3,3,200,3]
[1,3,200,3]
>>> import Data.Semigroup
>>> V.uniq $ V.fromList [ Arg 1 'a', Arg 1 'b', Arg 1 'c']
[Arg 1 'a']