我有这个功能“路径”这3个参数:如何在haskell中编写嵌套的if语句?
path::String->String->String->IO()
path place1 dir place2 =
if place1 == "bedroom" && d == 'n' && place2 == "den"
then do
putStrLn "You are in a bedroom with a large, comfortable bed. It has been a long, tiresome day, and you would like nothing better than to go to sleep."
else
if place1 == "bedroom" && d == 'd' && place2 == "bed"
then describe "bed"
else
if place1 == "den" && d == 's' && place2 == "bedroom"
then describe "bedroom"
else
if place1 == "bed" && d == 'u' && place2 == "bedroom"
then describe "bedroom"
else putStrLn "Cannot go there!"
我想知道如何,如果这是具有多个条件和多个if语句的正确方法是什么?
BTW,它将可能是一个好主意,改变第二个参数的类型,使其比“Char”或“String”更有意义。 – leftaroundabout 2014-11-09 01:10:41