
12 Mar
2010
12 Mar
'10
1:41 p.m.
Am Freitag 12 März 2010 14:27:21 schrieb Luca Ciciriello:
Hi.
I know, this is a very basic question but I've had some trouble with it.
I've a list and I want to write a function
isHomogeneous :: [String] -> Bool
returning True is all the elements of the list are equals and False otherwise. In my first ugly test I've used a list-comprehension method, but I'm sure that exists a more elegant/short way to obtain the same result.
Thanks in advance for any answer.
isHomogeneous :: Eq a => [a] -> Bool isHomogeneous [] = True isHomogeneous (x:xs) = all (== x) xs
Luca