The cause for the error you’re getting here is the use of the name count&remove
: identifiers in Haskell have to be either alphanumeric (e.g. count_and_remove
) or symbolic (e.g. ==
, ++
, etc.). Identifiers can’t contain both alphanumeric characters and symbols.
But that’s just one problem. You also have a reference to y
on line 9 that doesn’t refer to anything. And you seem not to quite understand yet how pattern matching works in function definitions. For example, your first
function could be defined just as:
first (x:xs) = x
This isn’t great in itself, both because there’s a standard Prelude function called head
that does this, and because it’s what’s called a partial function (https://wiki.haskell.org/Partial_functions).
The same sort of comment applies to your count&remove
function, which you could write as:
count_and_remove xs = length xs - length (remove1 xs)
(No need to pattern match with (x:xs)
here.)
If you are looking for more learning resources, a popular tutorial is Learn You A Haskell. You can also ask for help on the haskell-beginners mailing list or have a conversation in the #haskell
channel on irc.freenode.net.