我是在职能范围内使用警卫,但不是在职能签署后立即使用。 警卫人员在职能范围内发言do。 我发现这一错误:
parse error on input `|
我认为,错误可能来自登革热,但我曾尝试过许多tation,但还是发现错误。 问,这是否是因为警卫在职能签字之后不是偶然的,这就是为什么出现错误?
感谢
<>12>
CODE: The user is suppose to guess a number , and the number will be compared with the random number if they are the same. If it is not correct then the user will guess till the "guess" variable in the function is zero. in every interation that value(guess) is decreased by one.
例如:puzz 12 5
。 用户可以进行5次猜测,随机数字将在1至12之间抽取。 也就是说,这一职能是怎样运作的,但并非在发挥作用。
puzz :: Int -> Int -> IO ()
puzz boundary guess = do
putStr "Guess"
-- putStr -- I have to print (1 .. guess) here in each iteration
putStr ":"
x <- randomRIO (1, boundary :: Int)
n <- getLine
let
nTo = read n::Int
in print x
| guess == 0 = putStr "You couldn t guess right,the correct answer is" ++ x
| nTo > x = putStr "lower"
| nTo < x = putStr "higer"
| nTo == x = putStr "Congrat, You guess right."
| otherwise raad boundary (guess - 1)
put:
Main> puzz 50 6
Guess a number betwee 1 en 50.
Guess 1: 49
lower
Guess 2: 25
lower
Guess 3: 12
higher
Guess 4: 18
higher
Guess 5: 21
higher
Guess 6: 23
lower
You couldn t guess correct, the answer was: 22.
感谢 for your help