summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-07-09 20:38:07 +0000
committerVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-07-09 20:38:07 +0000
commit48d2f412115b56af091d54c93cee057b1ba7d382 (patch)
treede831c74ecf19d8206c91835a6b971037169483b /lib
parent07bd78f10f2bcce8a5e9838d73754ab4d27f6d1c (diff)
generalised foldVector
Diffstat (limited to 'lib')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index dfa2e86..c73ef10 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -339,8 +339,9 @@ unzipVectorWith f g u = unsafePerformIO $ do
339 return (v,w) 339 return (v,w)
340{-# INLINE unzipVectorWith #-} 340{-# INLINE unzipVectorWith #-}
341 341
342foldVector :: Storable a => (a -> b -> b) -> b -> Vector a -> b
342foldVector f x v = unsafePerformIO $ 343foldVector f x v = unsafePerformIO $
343 unsafeWith (v::Vector Double) $ \p -> do 344 unsafeWith v $ \p -> do
344 let go (-1) s = return s 345 let go (-1) s = return s
345 go !k !s = do y <- peekElemOff p k 346 go !k !s = do y <- peekElemOff p k
346 go (k-1::Int) (f y s) 347 go (k-1::Int) (f y s)