head' :: [a] -> a
head' [] = error "No head for empty lists!"
head' (x:_) = x
head' :: [a] -> a
head' xs = case xs of [] -> error "No head for empty lists!"
(x:_) -> x
I am asking for a fairly easy question which I don't understand.
In the code above, I see that it takes a list for an input.
But on the third line, it says (x:_)
which confuses me.
Can anyone explain to me why they wrote (x:_)
instead of [x:_]
?
And plus, I don't understand what (x:_)
means.
Thank you.