我如何开始解决 haskell 中的单词链?
How can I start to solve a word chain in haskell?
Let us know if the word chain game was played correctly! The object of the game is to form another word with the last letter of the previous word. The words are separated by a space. The words function can help you solve this problem.
Each of the following test cases must give a True:
validGame "alma asztal lo olalkodik kutya" == True
validGame "konverv veg golya abrosz zsifaf fules" == True
validGame "erdo osztokel nyugat tabortuz" == False
validGame "zokog guzsalyas sararany nyul leng" == False
validGame :: String -> Bool
validGame (x:' ':z:xs) = (x==z) && validGame (z:xs)
validGame (x:xs) = validGame xs
validGame [] = True
Let us know if the word chain game was played correctly! The object of the game is to form another word with the last letter of the previous word. The words are separated by a space. The words function can help you solve this problem.
Each of the following test cases must give a True:
validGame "alma asztal lo olalkodik kutya" == True
validGame "konverv veg golya abrosz zsifaf fules" == True
validGame "erdo osztokel nyugat tabortuz" == False
validGame "zokog guzsalyas sararany nyul leng" == False
validGame :: String -> Bool
validGame (x:' ':z:xs) = (x==z) && validGame (z:xs)
validGame (x:xs) = validGame xs
validGame [] = True