[Haskell-cafe] Odd lack of laziness

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Jun 23 05:38:42 EDT 2007


2007/6/22, Andrew Coppin <andrewcoppin at btinternet.com>:
> Chaddaï Fouché wrote:
> > You should be using BS.null f rather than BS.length f > 0.
> >
> While we're on the subject... anybody know a neat way to check, say,
> whether a list contains exactly 1 element? (Obviously pattern matching
> can do it, but that requires big case-expressions...)
>

Big case-expression ?
isLength1 [x] = "Ok"
isLength _ = "Nok"

How is [x] big in any way ? If you need to test for more than one
element you can just put put a guard with length

-- 
Jedaï


More information about the Haskell-Cafe mailing list