News for hackers. Stuff that matters.
Re:Haskell One Liners to Impress Your Friends by jbri on Saturday June 04, 2011 @04:54AM (#2619187)
scan is similar to fold - except instead of the result being the final value, it's a list of all the intermediate values up to the final one (if it exists - scanl is productive and can handle infinite lists just fine).

So the first fibonacci number is 1 (we're concatenating it onto the front of the list), the second fibonacci number is also one (the second argument to scan), and every fibonacci number after that is the sum of the previous number (scan's running total) and the one before that.

There are no comments on this comment yet.