[Haskell-cafe] testing for same characters in lists of strings

Henning Thielemann lemming at henning-thielemann.de
Tue Apr 8 16:10:54 EDT 2008


On Tue, 8 Apr 2008, Jackm139 wrote:

>
> Thanks for all the replies!
> I have it working somewhat.  It works as long as there is only one string in
> each list, but if the lists contain more than one string it fails. here is
> what I have:
>
>
> import List
>
> same :: [[Char]] -> [[Char]] -> Bool
> same [xs] [ys] = map (normalize) [[xs]] == map (normalize) [[ys]]
>
> normalize :: [String] -> [String]
> normalize [xs] = [(sort (nub xs))]

'normalize' (if correctly implemented) is essentially the same as 
'Data.Set.fromList'


More information about the Haskell-Cafe mailing list