[Issue 11084] std.algorithm.scan

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 21 06:04:43 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11084



--- Comment #2 from bearophile_hugs at eml.cc 2013-09-21 06:04:43 PDT ---
(In reply to comment #1)
> Intermediate? Can you be more specific? What exact steps does that scan!() call
> make?

The Haskell scanl is a very simple function, it acts very much like reduce, but
instead of returning just the last result, it returns them all:

scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]


Its whole Haskell implementation in the Haskell Prelude:

scanl :: (a -> b -> a) -> a -> [b] -> [a]
scanl f q ls =  q : (case ls of
                     []   -> []
                     x:xs -> scanl f (f q x) xs)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list