指定された文字列のすべてのプレフィックスのリストを返す関数を作成します。
これは私が今のところいるところです。
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"
私はアイデアがありません。ヒントはありますか?