Hacker News new | ask | show | jobs
by shadowfox 5557 days ago
I think I didn't get this :( Care to explain?
2 comments

    main=print n
    n=42
In C or Python, this would print 0 or undef or some random contents. In Haskell, it prints 42. The "assignment" reaches back to instructions before itself. Which ought to hint it's not really an assignment in the (my) usual sense of the word.
In Haskell, I can:

    x = 0:y
    y = 1:x
    main = print $ take 10 y
Producing output:

    [1,0,1,0,1,0,1,0,1,0]