readMaybe package:vector

Yield the element at the given position. Returns Nothing if the index is out of range.

Examples

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

>>> v <- MV.generate 10 (\x -> x*x)

>>> MV.readMaybe v 3
Just 9

>>> MV.readMaybe v 13
Nothing
Yield the element at the given position. Returns Nothing if the index is out of range.

Examples

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

>>> v <- MV.generate 10 (\x -> x*x)

>>> MV.readMaybe v 3
Just 9

>>> MV.readMaybe v 13
Nothing
Yield the element at the given position. Returns Nothing if the index is out of range.

Examples

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

>>> v <- MVP.generate 10 (\x -> x*x)

>>> MVP.readMaybe v 3
Just 9

>>> MVP.readMaybe v 13
Nothing
Yield the element at the given position. Returns Nothing if the index is out of range.

Examples

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

>>> v <- MVS.generate 10 (\x -> x*x)

>>> MVS.readMaybe v 3
Just 9

>>> MVS.readMaybe v 13
Nothing
Yield the element at the given position. Returns Nothing if the index is out of range.

Examples

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

>>> v <- MVU.generate 10 (\x -> x*x)

>>> MVU.readMaybe v 3
Just 9

>>> MVU.readMaybe v 13
Nothing