on master help sign in
Add doc implementing scanl' in terms of scan
commita7a6c27216cb464996a44fe39f40b7c4c86e788a authorHarendra Kumar <harendra@composewell.com> dateTue 1 Mar 2022, 14:21 (5 years ago) parentd6f9e6e
1 file changed+2
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+2
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+2
@@ -793,6 +793,7 @@ scanlM' step begin m = fromStreamD $ D.scanlM' step begin $ toStreamD m
793793-- lazy expressions inside the accumulator, it is recommended that a strict
794794-- data structure is used for accumulator.
795795--
796+-- >>> scanl' step z = scan (Fold.foldl' step z)
796797-- >>> scanl' f z xs = scanlM' (\a b -> return (f a b)) (return z) xs
797798-- >>> scanl' f z xs = z `Stream.cons` postscanl' f z xs
798799--
@@ -805,6 +806,7 @@ scanl' step z m = fromStreamS $ S.scanl' step z $ toStreamS m
805806
806807-- | Like 'scanl'' but does not stream the initial value of the accumulator.
807808--
809+-- >>> postscanl' step z = postscan (Fold.foldl' step z)
808810-- >>> postscanl' f z = postscanlM' (\a b -> return (f a b)) (return z)
809811-- >>> postscanl' f z xs = Stream.drop 1 $ Stream.scanl' f z xs
810812--