diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 13 |
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) | |||
96 | infixl 9 |> | 96 | infixl 9 |> |
97 | n |> l = if length l == n then fromList l else error "|> with wrong size" | 97 | n |> 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 | |||
101 | It may safely be used, for instance, with infinite lists. | ||
102 | -} | ||
103 | (|>|) :: (Storable a) => Int -> [a] -> Vector a | ||
104 | infixl 9 |>| | ||
105 | n |>| 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 |
100 | at' :: Storable a => Vector a -> Int -> a | 113 | at' :: Storable a => Vector a -> Int -> a |
101 | at' v n = safeRead v $ flip peekElemOff n | 114 | at' v n = safeRead v $ flip peekElemOff n |