【发布时间】:2021-08-01 09:41:42
【问题描述】:
我正在尝试编写一个函数来检查给定列表是否是回文。但是,我不知道如何将函数应用于给定的输入。 我的代码如下所示:
isPalindrome :: [a] -> Bool
isPalindrome x
| head x == last x = True
| otherwise = isPalindrome tail (init x)
这不起作用,我不知道为什么。
【问题讨论】:
-
在语法上,您的意思是
isPalindrome (tail (init x)),带有额外的一对括号。
标签: list haskell palindrome