scanr -package:jsaddle

scanr is the right-to-left dual of scanl. Note that the order of parameters on the accumulating function are reversed compared to scanl. Also note that
head (scanr f z xs) == foldr f z xs.

Examples

>>> scanr (+) 0 [1..4]
[10,9,7,4,0]
>>> scanr (+) 42 []
[42]
>>> scanr (-) 100 [1..4]
[98,-97,99,-96,100]
>>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]
>>> force $ scanr (+) 0 [1..]
*** Exception: stack overflow
scanr is the right-to-left dual of scanl. Note that
head (scanr f z xs) == foldr f z xs.
scanr is similar to foldr, but returns a list of successive reduced values from the right.
scanr f z [..., x{n-1}, xn] == [..., x{n-1} `f` (xn `f` z), xn `f` z, z]
Note that
head (scanr f z xs) == foldr f z xs
last (scanr f z xs) == z
scanr is the right-to-left dual of scanl.
scanr is similar to foldr, but returns a list of successive reduced values from the right.
scanr f z [..., x{n-1}, xn] == [..., x{n-1} `f` (xn `f` z), xn `f` z, z]
Note that
head (scanr f z xs) == foldr f z xs
last (scanr f z xs) == z
O(n) scanr is the right-to-left dual of scanl. Performs replacement on invalid scalar values.
scanr f v == reverse . scanl (flip f) v . reverse
scanr is the right-to-left dual of scanl.
scanr is the right-to-left dual of scanl. Note that the order of parameters on the accumulating function are reversed compared to scanl. Also note that
head (scanr f z xs) == foldr f z xs.
>>> scanr (+) 0 [1..4]
[10,9,7,4,0]

>>> scanr (+) 42 []
[42]

>>> scanr (-) 100 [1..4]
[98,-97,99,-96,100]

>>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]

>>> force $ scanr (+) 0 [1..]
*** Exception: stack overflow
Like scan but start scanning from the right
scanr is the right-to-left dual of scanl.
scanr is the right-to-left dual of scanl. Note that
head (scanr f z xs) == foldr f z xs.
O(n) Right-to-left Haskell-style scan
O(n) Right-to-left Haskell-style scan
O(n) Right-to-left Haskell-style scan
O(n) Right-to-left Haskell-style scan
Equivalent to scanr from Data.List when applied to a String, but preserves all non-character data.
scanr is the right-to-left dual of scanl.
O(n) Right-to-left Haskell-style scan.
O(n) Right-to-left Haskell-style scan.
O(n) Right-to-left Haskell-style scan.
O(n) Right-to-left Haskell-style scan.
O(n) Right-to-left Haskell-style scan.
scanr is similar to foldr, but returns a vector of successive reduced values from the right:
scanr f z (... :> xn1 :> xn :> Nil) == ... :> (xn1 `f` (xn `f` z)) :> (xn `f` z) :> z :> Nil
>>> scanr (+) 0 (5 :> 4 :> 3 :> 2 :> Nil)
14 :> 9 :> 5 :> 2 :> 0 :> Nil
"scanr f z xs" corresponds to the following circuit layout:
  • NB:
    head (scanr f z xs) == foldr f z xs
  • For a different trade-off between circuit size and logic depth for associative operators, see Clash.Sized.RTree#scans