相关疑难解决方法(0)

Haskell空间溢出

我编译了这个程序,并试图运行它.

import Data.List
import Data.Ord
import qualified Data.MemoCombinators as Memo

collatzLength :: Int -> Int
collatzLength = Memo.arrayRange (1, 1000000) collatzLength'
  where
    collatzLength' 1 = 1
    collatzLength' n | odd n  = 1 + collatzLength (3 * n + 1)
                     | even n = 1 + collatzLength (n `quot` 2)

main = print $ maximumBy (comparing fst) $ [(collatzLength n, n) | n <- [1..1000000]]
Run Code Online (Sandbox Code Playgroud)

我从GHC获得以下内容

Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it. …
Run Code Online (Sandbox Code Playgroud)

haskell ghc

9
推荐指数
3
解决办法
2943
查看次数

标签 统计

ghc ×1

haskell ×1