我想写一个简单的游戏“猜数字”——n
尝试。我想添加一些条件和命中。是否可以在块内使用警卫do
?
这是我的代码:
game = return()
game n = do putStrLn "guess number: 0-99"
number<-getLine
let y = read number
let x =20
| y>x = putStrLn "your number is greater than x"
| y<x = putStrLn "your number is less than x"
| y==x putStrLn "U win!!"
| otherwise = game (n-1)
已经有错误
error: parse error on input ‘|’
它可以用一些空白来修复,还是不可能做到?