
12 Mar
2010
12 Mar
'10
1:53 p.m.
This is not bad, I think Daniel's version is a bit more elegant. One point though, whenever you see "then True else False" you can just remove the conditional. if cexp then True else False is the same as just 'cexp' Your last line becomes simply: isHomogeneous (x:xs) = x == head xs && isHomogeneous xs
I'm a total beginner, so I don't know if this is the best way, but I tried:
isHomogeneous :: [String] -> Bool
isHomogeneous [] = True isHomogeneous [x] = True isHomogeneous (x:xs) = if x == head xs && isHomogeneous xs then True else False
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.