summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Vector.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index d410c4d..0e6b3f4 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -96,6 +96,19 @@ toList v = safeRead v $ peekArray (dim v)
96infixl 9 |> 96infixl 9 |>
97n |> l = if length l == n then fromList l else error "|> with wrong size" 97n |> l = if length l == n then fromList l else error "|> with wrong size"
98 98
99{- | Like '(|>)', but explicitly truncates the list, if it is too long.
100
101It may safely be used, for instance, with infinite lists.
102-}
103(|>|) :: (Storable a) => Int -> [a] -> Vector a
104infixl 9 |>|
105n |>| l = if length l' == n then
106 fromList l'
107 else
108 error "|>|: list too short"
109 where l' = take n l
110
111
99-- | access to Vector elements without range checking 112-- | access to Vector elements without range checking
100at' :: Storable a => Vector a -> Int -> a 113at' :: Storable a => Vector a -> Int -> a
101at' v n = safeRead v $ flip peekElemOff n 114at' v n = safeRead v $ flip peekElemOff n