How to avoid stack space overflows?

后端 未结 3 1204
迷失自我
迷失自我 2021-02-06 14:20

I\'ve been a bit surprised by GHC throwing stack overflows if I\'d need to get value of large list containing memory intensive elements. I did expected GHC has TCO so I\'ll neve

3条回答
  •  悲哀的现实
    2021-02-06 15:02

    All of the definitions (except the useless fib_at) will delay all the + operations, which means that when you have selected the millionth element it is a thunk with a million delayed additions. You should try something stricter.

提交回复
热议问题