[Haskell-cafe] Producing MinimumValue
Benja Fallenstein
benja.fallenstein at gmail.com
Fri Jul 20 10:10:15 EDT 2007
2007/7/19, Jason Dagit <dagit at codersbase.com>:
> > 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
More information about the Haskell-Cafe
mailing list