小编sch*_*guy的帖子

为什么这个函数中有非详尽的模式?

在这个脚本中,

permutations :: Integer -> Integer -> Integer
permutations x y
            | x==x-(y-1)     = x
            | (x>0) && (y>0) = permutations (x-1) y * x
Run Code Online (Sandbox Code Playgroud)

我想知道为什么在函数排列中存在非穷举模式.

请帮我.

非常感谢你的进步!

haskell

2
推荐指数
1
解决办法
102
查看次数

Haskell:IO程序中的解析错误

我正在写一个程序来帮助我的弟弟学习加法.我没有编写IO程序的经验,而且我遇到了这个解析错误:

MyCode.hs:6:25:
    Parse error in pattern: show
    Possibly caused by a missing 'do'?
Run Code Online (Sandbox Code Playgroud)

代码:

mathExercise times (a,b) = 
    if times<=0
    then return ()
    else do let x = randInt a
            let y = randInt b 
            putStr (show x ++ " + "++ show y++ " = ")
            ans <- getInt
            if (ans==x+y)
            then do print True
                    mathExercise (times-1) (a,b)
            else do print False
Run Code Online (Sandbox Code Playgroud)

haskell parse-error

2
推荐指数
1
解决办法
1299
查看次数

标签 统计

haskell ×2

parse-error ×1