Scanning in Haskell
31 Dec 2012In a previous post, I had written about [Folding in Haskell](/2012/12/27/folding-in-haskell.html] which in itself is a very powerful tool. We spent a brief moment in that tutorial actually working through a problem and writing the folding process out long hand.
Well, scanning scanl and scanr does this for you! It shows you the reduction steps in the form of an array returned back to you.
A quick example:
Here you can see the fold’s process “working-sheet”.
120 being the overall answer as demonstrated by the foldl call above.
Easy.