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
Run Code Online (Sandbox Code Playgroud)
我要求一个相当容易的问题,我不明白.在上面的代码中,我看到它需要一个输入列表.但在第三行,它说(x:_)哪些让我感到困惑.任何人都可以向我解释为什么他们写(x:_)而不是[x:_]?
而且,我不明白是什么(x:_)意思.
谢谢.