View Full Version : Haskell. Ammount of elements.

12-20-2010, 02:25 PM
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
lexical error in string/character literal at character 'a'

what is the problem?