In Haskell I have this main function:
combinations pre suf letters = prefixed ++ suffixed
where
perms = permutation letters
prefixed = map (\x -> pre ++ x) $ perms
suffixed = map (\x -> x ++ suf) $ perms
main = do
ls1 <- fmap lines (readFile "dictionary.txt")
let ls2 = combinations "Apple" "Citrus" "Banana"
How can I combine ls1 and ls2 and print out the double ones? The double ones has to be non case sensitive. So if I have Banana and banana it have to print 1 of the ones.
Edit:
ls1 is a list of lines from dictionary.txt
ls2 is a list of different combinations from an other function called combinations
I want to combine/merge/concat ls1 and ls2. To a list like ls3. This list will have all lines from dictionary.txt and alle combinations from ls2 and the combinations function.
Then it must print alle the double elements in ls3 as output.
Edit 2:
The structure of dictionary.txt (Just a random list with a lot of words in it. ) is like:
Apple
Strawberry
Clown
.....
The combinations function (see edit in my code): Makes from a input like:
combinations "a" "b" "ded"
Output:
["acd","adc","cdb","dcb"]
Background: Application is for a game like scrabble: "pre" and "suf" are the characters on the board. And "letters" are the letters of the player.
Example values:
ls1
["Apple","Strawberry","Clown".....]
ls2
["Clwno","Clonw","Clown"..]
ls3
["Apple","Strawberry","Clown","Clwno","Clonw","Clown"]
In ls3 now you see 2 times the word "Clown". As output I want:
["Clown"]
This is what I mean with double words in ls3.
"dictionary.txt"
, we don't know whatcombination
does, and we can only guess what you mean by "double elements". Just give example values forls1
andls2
, and what you expect to find inls3
. – user824425