我要编写一个函数,它返回给定字符串的所有前缀列表。
这就是我目前所处的位置。
prefixess [x] [] = [x]
prefixess [] s = prefixess [s] s
prefixess [x] s = prefixess [x, (init s)] (init s)
prefixes s = prefixess [] s
它可以编译,但是当我尝试在字符串上运行它时,我得到了这个:
Couldn't match type ‘Char’ with ‘[t]’
Expected type: [[t]]
Actual type: [Char]
Relevant bindings include
it :: [t] -> [[t]] (bound at <interactive>:18:1)
In the first argument of ‘prefixess’, namely ‘"abcde"’
In the expression: prefixess "abcde"
In an equation for ‘it’: it = prefixess "abcde"
我没主意了。有什么提示吗?