我在看的代码包含这个顶级功能:解释
starman :: String -> Int -> IO()
starman word n = turn word ['-' | x <- word] n
我可以看到,这是一个函数,需要两个参数,然后调用转功能,看起来像这样:
turn :: String -> String -> Int -> IO()
turn word display n =
do if n==0
then putStrLn "You lose"
else if word==display
then putStrLn "You win!"
else mkguess word display n
什么我不明白是什么意思呢:
word ['-' | x <- word]
的'replicate'版本不具有无限字符串的工作。 – melpomene
是的。我想这在这里不可能。 – smarx
@melpomene不,但在转向功能中使用的== ==。无限列表在这里不是真正的问题。 – Cubic