Hello, the following code is the wordfeud program. This allows you to search for a list of words matching the prefix, suffix, and some letters. My question is that instead of using the list below, I want to use an external text file containing words and load it into the list. How can I do it?
count :: String -> String -> Int count _[] = 0 count [] _ = 0 count (x:xs) square |x `elem` square = 1 + count xs (delete x square) |otherwise = count xs square check :: String -> String -> String -> String -> Bool check prefix suffix word square | (length strippedWord) == (count strippedWord square) = True | otherwise = False where strippedWord = drop (length prefix) (take ((length word ) - (length suffix)) word) wordfeud :: String -> String -> String -> [String] wordfeud abc = test1 where test =["horse","chair","chairman","bag","house","mouse","dirt","sport"] test1 = [x| x <- test, a `isPrefixOf` x, b `isSuffixOf` x, check abxc]
source share