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
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
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:
head (scanr f z xs) == foldr f z xs