Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --compatability
  2. compatibility :: String -> String -> String
  3. compatibility a b =
  4.     a ++ (reaction (overlay 1 (removelikechars a b))) ++ b ++ " and " ++ b ++ (reaction (overlay 1 (removelikechars b a))) ++ a
  5.         where
  6.             reaction :: String -> String
  7.             reaction [] = []
  8.             reaction a
  9.                 | drop (length a - 1) a == "l" = " loves "
  10.                 | drop (length a - 1) a == "p" = " is physically attracted to "
  11.                 | drop (length a - 1) a == "h" = " hates "
  12.                 | drop (length a - 1) a == "i" = " is indifferent to "
  13.                 | otherwise = "ERROR"
  14.             overlay :: Int -> String -> String
  15.             overlay _ [] = []
  16.             overlay n (x:xs)
  17.                 | n == 1 = ("l" ++ overlay 2 xs)
  18.                 | n == 2 = ("p" ++ overlay 3 xs)
  19.                 | n == 3 = ("h" ++ overlay 4 xs)
  20.                 | n == 4 = ("i" ++ overlay 1 xs)
  21.                 | otherwise = "ERROR"
  22.             removelikechars :: String -> String -> String
  23.             removelikechars [] _ = []
  24.             removelikechars a b =
  25.                 if ((length [y | y <- b, [y] == (take 1 a)]) > 0)
  26.                     then
  27.                         removelikechars (drop 1 a) b
  28.                     else
  29.                         (take 1 a) ++ removelikechars (drop 1 a) b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement