2007/7/19, Jason Dagit <[EMAIL PROTECTED]>:
> I prefer,
>
> allEqual [] = True
> allEqual xs = foldl1 (==) xs
>
> But, unfortunately, it's not a one liner like yours (unless you allow
> allEqual [] = undefined).

Oh and silly me, that only works for [Bool].

My natural instinct is,

allEqual [] = True
allEqual (x:xs) = all (== x) xs

with the same caveat about allEqual [] as in your case.

- Benja
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to