scanr package:vector

O(n) Right-to-left scan.
O(n) Right-to-left scan.
O(n) Right-to-left scan.
O(n) Right-to-left scan.
O(n) Right-to-left scan.
O(n) Right-to-left scan with strict accumulator.
O(n) Right-to-left, initial-value free scan over a vector. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector as V

>>> V.scanr1 min $ V.fromListN 5 [3,1,4,2,4]
[1,1,2,2,4]

>>> V.scanr1 max $ V.fromListN 5 [4,5,2,3,1]
[5,5,3,3,1]

>>> V.scanr1 min (V.empty :: V.Vector Int)
[]
O(n) Right-to-left, initial-value free scan over a vector with a strict accumulator. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector as V

>>> V.scanr1' min $ V.fromListN 5 [3,1,4,2,4]
[1,1,2,2,4]

>>> V.scanr1' max $ V.fromListN 5 [4,5,2,3,1]
[5,5,3,3,1]

>>> V.scanr1' min (V.empty :: V.Vector Int)
[]
O(n) Right-to-left scan with strict accumulator.
O(n) Right-to-left, initial-value free scan over a vector. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.scanr1 min $ V.fromListN 5 [3,1,4,2,4]
[1,1,2,2,4]

>>> V.scanr1 max $ V.fromListN 5 [4,5,2,3,1]
[5,5,3,3,1]

>>> V.scanr1 min (V.empty :: V.Vector Int)
[]
O(n) Right-to-left, initial-value free scan over a vector with a strict accumulator. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.scanr1' min $ V.fromListN 5 [3,1,4,2,4]
[1,1,2,2,4]

>>> V.scanr1' max $ V.fromListN 5 [4,5,2,3,1]
[5,5,3,3,1]

>>> V.scanr1' min (V.empty :: V.Vector Int)
[]
O(n) Right-to-left scan with strict accumulator.
O(n) Right-to-left, initial-value free scan over a vector. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> VP.scanr1 min $ VP.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VP.scanr1 max $ VP.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VP.scanr1 min (VP.empty :: VP.Vector Int)
[]
O(n) Right-to-left, initial-value free scan over a vector with a strict accumulator. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> VP.scanr1' min $ VP.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VP.scanr1' max $ VP.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VP.scanr1' min (VP.empty :: VP.Vector Int)
[]
O(n) Right-to-left scan with strict accumulator.
O(n) Right-to-left, initial-value free scan over a vector. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.scanr1 min $ VS.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VS.scanr1 max $ VS.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VS.scanr1 min (VS.empty :: VS.Vector Int)
[]
O(n) Right-to-left, initial-value free scan over a vector with a strict accumulator. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.scanr1' min $ VS.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VS.scanr1' max $ VS.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VS.scanr1' min (VS.empty :: VS.Vector Int)
[]
O(n) Right-to-left scan with strict accumulator.
O(n) Right-to-left, initial-value free scan over a vector. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.scanr1 min $ VU.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VU.scanr1 max $ VU.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VU.scanr1 min (VU.empty :: VU.Vector Int)
[]
O(n) Right-to-left, initial-value free scan over a vector with a strict accumulator. Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.scanr1' min $ VU.fromListN 5 [3,1,4,2,4 :: Int]
[1,1,2,2,4]

>>> VU.scanr1' max $ VU.fromListN 5 [4,5,2,3,1 :: Int]
[5,5,3,3,1]

>>> VU.scanr1' min (VU.empty :: VU.Vector Int)
[]
O(n) Right-to-left scan over a vector with its index.
O(n) Right-to-left scan over a vector (strictly) with its index.
O(n) Right-to-left postscan.
O(n) Right-to-left postscan with strict accumulator.
O(n) Right-to-left prescan.
prescanr f z = reverse . prescanl (flip f) z . reverse