modify package:vector

Apply a destructive operation to a vector. The operation may be performed in place if it is safe to do so and will modify a copy of the vector otherwise (see New for details).

Examples

>>> import qualified Data.Vector as V

>>> import qualified Data.Vector.Mutable as MV

>>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
"xaaa"
Apply a destructive operation to a vector. The operation may be performed in place if it is safe to do so and will modify a copy of the vector otherwise (see New for details).

Examples

>>> import qualified Data.Vector.Strict as V

>>> import qualified Data.Vector.Strict.Mutable as MV

>>> V.modify (\v -> MV.write v 0 'x') $ V.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be performed in place if it is safe to do so and will modify a copy of the vector otherwise (see New for details).

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> import qualified Data.Vector.Primitive.Mutable as MVP

>>> VP.modify (\v -> MVP.write v 0 'x') $ VP.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be performed in place if it is safe to do so and will modify a copy of the vector otherwise (see New for details).

Examples

>>> import qualified Data.Vector.Storable as VS

>>> import qualified Data.Vector.Storable.Mutable as MVS

>>> VS.modify (\v -> MVS.write v 0 'x') $ VS.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Apply a destructive operation to a vector. The operation may be performed in place if it is safe to do so and will modify a copy of the vector otherwise (see New for details).

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> import qualified Data.Vector.Unboxed.Mutable as MVU

>>> VU.modify (\v -> MVU.write v 0 'x') $ VU.replicate 4 'a'
"xaaa"
Modify the element at the given position.
Modify the element at the given position using a monadic function.
Modify the element at the given position using a monadic function.
Modify the element at the given position using a monadic function.
Modify the element at the given position using a monadic function.
Modify the element at the given position using a monadic function.
Modify the element at the given position. No bounds checks are performed.
Modify the element at the given position using a monadic function. No bounds checks are performed.
Modify the element at the given position. No bounds checks are performed.
Modify the element at the given position using a monadic function. No bounds checks are performed.
Modify the element at the given position. No bounds checks are performed.
Modify the element at the given position using a monadic function. No bounds checks are performed.
Modify the element at the given position. No bounds checks are performed.
Modify the element at the given position using a monadic function. No bounds checks are performed.