fork download
  1. isPrefix :: Eq a => [a] -> [a] -> Bool
  2. isPrefix [] _ = True
  3. isPrefix _ [] = False
  4. isPrefix (x:xs) (y:ys) = x == y && isPrefix xs ys
  5.  
  6. result xs ys zs = isPrefix xs ys && isPrefix (reverse xs) (reverse zs)
  7.  
  8. main = do
  9. print $ result [1,2] [1,2,3] [3,1,2]
  10. print $ result [1,2] [1,2,3] [3,2,2]
  11. print $ result [1,2] [1,3,3] [3,1,2]
  12. print $ result [1,2] [1,2,3] [1]
  13.  
Success #stdin #stdout 0s 4544KB
stdin
Standard input is empty
stdout
True
False
False
False