Prelude> let filter' p (x:xs) | p x = x : filter' p xs | otherwise = filter' p xs
Prelude> let filter' _ [] = []
Prelude> filter' odd [1..10]
*** Exception: <interactive>:1:5-21: Non-exhaustive patterns in function filter'
我错过了什么模式?
Prelude> :{
Prelude| let filter' p (x:xs)
Prelude| | p x = x : filter' p xs
Prelude| | otherwise = filter' p xs
Prelude| let filter' _ [] = []
Prelude| :}
<interactive>:2:5: parse error (possibly incorrect indentation)
在 ghci 中定义这个(语法方面)的惯用方式是什么?排队是=
怎么回事 - 在我定义它们之前,我不知道要为以下子句留多少空间!:{}: 是怎么回事,有更好的方法吗?