I have such code:
Prelude> let n = [1,2,3,4]
Prelude> n
[1,2,3,4]
Prelude> 0:n
[0,1,2,3,4]
Prelude> let n = 0:n
And when I type in Haskell interpreter after upper:
Prelude> n
I’m getting the infinite result:
[0,0,0,0,0,0,0,0,0
And where printing ” 0, ” is infinite.
Why do I get such result?
Is there some recursive stuff, and why/how does it work in interpreater level?
Could I catch stack overflow, which such stuff on GHCi or not?
Thanks,
Best Regards!
What Josh is saying is that you definition of n expands as: