Reputation: 1124
Hey guys so I'm trying to create a simple program to delete the first occurence of a element then return the rest of the list. It's been a while and I'm wondering why I'm getting this parse error on line 8
module deleteFirst where
deleteFirst :: (Eq a) => a ->[a] -> [a]
deleteFirst toDelete [] = []
deleteFirst toDelete (a:as) =
if(toDelete == a) then as
else a:(deleteFirst toDelete as)
Any input? Thanks guy
Upvotes: 0
Views: 145
Reputation: 54584
You got the answer, but I'd like to point out another solution:
deleteFirst x xs = u ++ (drop 1 v) where (u,v) = break (==x) xs
Upvotes: 2
Reputation: 152837
The parse error is on column 8, not line 8, and it is because module names must start with an upper case letter.
Upvotes: 7