I have a 2 lists of strings
eg:
listx = ["name","age","rank"]
input = ["name","age"]
How can I compare the two lists to check whether the listx contains "name" & "age" given in input?
all (flip elem listx) input
comes to mind. No idea how efficient it is though...
elem listx) input". @dlna: basically it expands to "all (\x -> x elem listx) input", which ensures that for every element of input, that it is an element of listxIs this homework? :)
You need to create one or two recursive functions to walk through both lists, and search for every string in the input.
Or, you could look up some good functions in the Prelude that helps here.
elem listx |x <- input] error: - Type error in explicitly typed binding *** Term : inputIndex *** Type : [String] -> [String] -> [a] *** Does not match : [String] -> [String] -> Boolelem listx |x <- input]"