You are viewing a single comment's thread. Return to all comments →
11/15
pack :: [a] -> [(a,a)] pack [] = [] pack [x] = [] pack (x:y:xs) = (x,y) : pack xs f :: Eq a => [a] -> [a] -> Bool f xs ys = acc xs ys (length ys) where acc [] [] _ = True acc xs ys n | length xs < n = False | otherwise = if take n xs == ys then True else acc (tail xs) ys n showRes :: Bool -> String showRes True = "YES" showRes _ = "NO" main :: IO() main = do _ <- getLine inp <- getContents mapM_ putStrLn $ map showRes $ map (uncurry f) $ pack $ lines inp
Substring Searching
You are viewing a single comment's thread. Return to all comments →
11/15