Skip to content

Commit 02d4dc8

Browse files
committed
Fixed indexed scanrs
May not be idea with respect to fusion.
1 parent 59a5ba3 commit 02d4dc8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Data/Vector/Generic.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,18 +1822,22 @@ scanr' f z = unstreamR . Bundle.scanl' (flip f) z . streamR
18221822
-- | /O(n)/ Right-to-left scan over a vector with its index
18231823
iscanr :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b
18241824
{-# INLINE iscanr #-}
1825-
iscanr f z =
1825+
iscanr f z v =
18261826
unstreamR
1827-
. inplace (S.scanl (flip $ uncurry f) z . S.indexed) (+1)
1827+
. inplace (S.scanl (flip $ uncurry f) z . S.indexedR n) (+1)
18281828
. streamR
1829+
$ v
1830+
where n = length v
18291831

18301832
-- | /O(n)/ Right-to-left scan over a vector (strictly) with its index
18311833
iscanr' :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b
18321834
{-# INLINE iscanr' #-}
1833-
iscanr' f z =
1835+
iscanr' f z v =
18341836
unstreamR
1835-
. inplace (S.scanl' (flip $ uncurry f) z . S.indexed) (+1)
1837+
. inplace (S.scanl' (flip $ uncurry f) z . S.indexedR n) (+1)
18361838
. streamR
1839+
$ v
1840+
where n = length v
18371841

18381842
-- | /O(n)/ Right-to-left scan over a non-empty vector
18391843
scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a

0 commit comments

Comments
 (0)