News for hackers. Stuff that matters.
Re:Why isn't Haskell popular in industry? by ithkuil on Tuesday August 03, 2010 @08:28AM (#1570884)
I understand that you wanted to make a simple example, I just wanted to expand a little bit the issue of laziness and make it look slightly less magic.

I found a fascinating examples of the expressiveness and beauty of haskell due to lazy evaluation, which I think is better suited for FP evangelism:

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

Here we are defining the fibonacci sequence in a declarative way, recursing with a recursive "call".

The way the 'fibs' function is coded directly reflects the definition of the fibonacci sequence itself:

The 'fibs' list is defined as a list containing the first 2 elements and then, as a tail, the result of the application of the + function on the previous pair of elements.

"You can borrow things from the future as long as you don't try to change them"

There are no comments on this comment yet.