Counters are initialized every time?

前端 未结 4 962
独厮守ぢ
独厮守ぢ 2021-01-18 02:17

I try to make a simple counter. My counters do not go up however. It seems to me as if they are re-initialized every time by the function \"inc\" or maybe the (n+1) does not

4条回答
  •  终归单人心
    2021-01-18 02:37

    Variables are immutable in Haskell. When you call inc f it returns a value of 0 + 1 which you promptly ignore. The value of f is 0 and will remain so for all time.

提交回复
热议问题