toList,
)
import qualified Data.Vector.Fixed as V (
+ (!),
length,
)
import Data.Vector.Fixed.Boxed
type Vec5 = Vec N5
--- | Unsafe indexing.
---
--- Examples:
---
--- >>> import Data.Vector.Fixed (mk2)
--- >>> let v1 = mk2 1 2 :: Vec2 Int
--- >>> v1 ! 1
--- 2
---
-(!) :: (Vector v a) => v a -> Int -> a
-(!) v1 idx = (toList v1) !! idx
-- | Safe indexing.
--
(!?) :: (Vector v a) => v a -> Int -> Maybe a
(!?) v1 idx
| idx < 0 || idx >= V.length v1 = Nothing
- | otherwise = Just $ v1 ! idx
+ | otherwise = Just $ v1 V.! idx
-- | Remove an element of the given vector.