PDA

View Full Version : Haskell. Ammount of elements.



akvarel
12-20-2010, 02:25 PM
Hello!
I have to write a function in haskell that will count a number of elements in one word.
for example
in 'n' ('function')
out 2

I thought of something lke this
elemChar :: Char->String->Int
elemChar _ [] = 0
elemChar z (x:xs)
|z==x = 1 + elemChar z xs
|otherwise = elemChar z xs

but it shows me
<interactive>:1:15:
lexical error in string/character literal at character 'a'


what is the problem?