[Haskell-beginners] homogeneous value list

Daniel Fischer daniel.is.fischer at web.de
Fri Mar 12 09:08:18 EST 2010


Am Freitag 12 März 2010 14:41:11 schrieb Daniel Fischer:
>
> isHomogeneous :: Eq a => [a] -> Bool
> isHomogeneous [] = True
> isHomogeneous (x:xs) = all (== x) xs
>

Variant, getting rid of the special case for an empty list:

isHomogeneous :: Eq a => [a] -> Bool
isHomogeneous xs = and (zipWith (==) xs (drop 1 xs))


More information about the Beginners mailing list