fork(2) download
  1. module Main where
  2.  
  3. import Data.List (tails)
  4.  
  5. type Pattern = String
  6.  
  7. match :: Pattern -> String -> Bool
  8. match [] xs = null xs
  9. match _ [] = False
  10. match ('*':xs) str = any (match xs) $ tails str
  11. match ('?':xs) str = match xs $ tail str
  12. match ('\\':x:xs) (y:ys) = x == y && match xs ys
  13. match (x:xs) (y:ys) = x == y && match xs ys
  14.  
  15. main = print $ match "as*d*?qwe*qwe" "as123dssqwe12345678qwe"
Success #stdin #stdout 0s 4644KB
stdin
Standard input is empty
stdout
True