Shimuuar marked this pull request as ready for review
March 12, 2021 16:47| -- and fill it with the results of applying the function to each index. | ||
| generate :: (PrimMonad m, MVector v a) => Int -> (Int -> a) -> m (v (PrimState m) a) | ||
| {-# INLINE generate #-} | ||
| generate n f = stToPrim $ generateM n (return . f) |
| -- | /O(n)/ Pure left fold (function applied to each element and its index). | ||
| ifoldl :: (PrimMonad m, MVector v a) => (b -> Int -> a -> b) -> b -> v (PrimState m) a -> m b | ||
| {-# INLINE ifoldl #-} | ||
| ifoldl f b0 v = stToPrim $ loop 0 b0 |
| prop_mut_foldrM' :: P ((a -> a -> Identity a) -> a -> v a -> Identity a) | ||
| = (\f z v -> Identity $ runST $ MV.foldrM' (\a b -> pure $ runIdentity $ f a b) z =<< V.thaw v) | ||
| `eq` | ||
| foldrM |
lehins pushed a commit that referenced this pull request
Apr 1, 2021Add generate, modifyM & folds for mutable vectors: * Added `generate`, `generateM` for mutable vectors * Added `modifyM` and `unsafeModifyM` for mutable vectors * Add all variants of folds for mutable vectors: * `mapM_`, `imapM_`, `forM_`, `iforM_` * `foldl`, `foldl'`, `foldM`, `foldM'`, * `foldr, `foldr'`, `foldrM`, `foldrM'`, * `ifoldl`, `ifoldl'`, `ifoldM`, `ifoldM'`, * `ifoldr`, `ifoldr'`, `ifoldrM, `ifoldrM'` * Add tests for all new functions * Update changelog
Closed
17 tasks