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

Henning Thielemann lemming at henning-thielemann.de
Tue Apr 8 01:33:36 EDT 2008


On Mon, 7 Apr 2008, Jackm139 wrote:

>
> I'm new to Haskell, and I'm finding it is very different from any other
> language I have worked with.
>
> I have an assignment to make a program to test whether two lists use the
> same characters for each string.
> e.g.
>
> sameCharacter ["rock", "cab"] ["cork", "abc"]
> True
>
> My plan to tackle this was to use:
> nub to eliminate duplications,
> sort to put the characters in order,
> and map to put characters together.. and then somehow check to see if these
> characters are the same.

How about converting the strings to Set Char and comparing the resulting 
lists?


More information about the Haskell-Cafe mailing list