0
주어진 문자열의 모든 접두어 목록을 반환하는 함수를 작성합니다.haskell의 접두어 목록
여기까지 내가 지금까지 있습니다.
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"
내가 아이디어에서 오전. 어떤 힌트?
좋아, 이것은 계몽적이었습니다. 나는 방금 ":"연산자가 어떻게 작동하는지에 관해 배웠다. 감사합니다. – Dystr