Suppose I have a list of Strings like this:
["aesfa","gwopq","awefg"]
I would want to get all possible combinations between those Strings, something like this:
["aga","agw","age","agf", ... ,"sga","sgw", ... , "aqf","aqg"]
The strings inside the list have all the same lenght, but could be any lenght, and the list could contain different numbers of strings
I tried the following list comprehensions:
-getCombinations (z:zs) = [x:y | x <- z, y <- zs]
This gives me, obviously, a list of the combinations between all the characters of the first string and the rest of the strings (not the characters).
-getCombinations (z:zs) = [x:y | x <- z, y <- getCombinations zs]
This doesnt work if I dont do a pattern matching for the empy list, I did it like this:
getCombinations [] = []
but doing that make the function return always the empty list no matter what
weirdly enough, if I do:
-getCombinations (z:zs) = [x:[y] | x <- z, y <- head zs]
it gives me the combinations between the first two strings
I tried to extend that to get another String and I ended up with this:
getCombinations (z:zs) = [x:[y]++[w] | x <- z, y <- (head zs), w <- (head(tail zs))]
That gave me the combinations of the first three strings