I have a function qpFunc that takes two strings. s:os and p:ps. I call this function recursivley and traverese thourgh a list. When s:os is empty, I want to call a new function itWilcard (p:ps). However, when trying to put it as a pattern-match, it complains that
"Variable not in scope: ps :: [Char]".
When used inside the function call it never reaches the condition it seems like since i get
"Non-exhaustive patterns in function qpFunc"
when calling it with "" "?".
How can I check if the lists used as arguments are empty and if so, apply a new function? In the question posted here question stackoverflow it says that
"x:xs is never empty: it always has element x. The canonical pattern for matching empty lists is []"
However, in my case I want to apply a function if the pattern is met.
This is my code so far:
qpFunc :: String -> String -> (String, String)
qpFunc [] [] = ("", "")
qpFunc [] _ = itWilcard (p : ps) -- does not work
qpFunc (s : os) (p : ps)
| (s : os) == [] = itWilcard (p : ps) -- never reached ?
| p == '*' = (os, p : ps)
| p == '?' = qpFunc os ps
| s == p = (os, ps)
| otherwise = ([], "#")