Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --compatability
- compatibility :: String -> String -> String
- compatibility a b =
- a ++ (reaction (overlay 1 (removelikechars a b))) ++ b ++ " and " ++ b ++ (reaction (overlay 1 (removelikechars b a))) ++ a
- where
- reaction :: String -> String
- reaction [] = []
- reaction a
- | drop (length a - 1) a == "l" = " loves "
- | drop (length a - 1) a == "p" = " is physically attracted to "
- | drop (length a - 1) a == "h" = " hates "
- | drop (length a - 1) a == "i" = " is indifferent to "
- | otherwise = "ERROR"
- overlay :: Int -> String -> String
- overlay _ [] = []
- overlay n (x:xs)
- | n == 1 = ("l" ++ overlay 2 xs)
- | n == 2 = ("p" ++ overlay 3 xs)
- | n == 3 = ("h" ++ overlay 4 xs)
- | n == 4 = ("i" ++ overlay 1 xs)
- | otherwise = "ERROR"
- removelikechars :: String -> String -> String
- removelikechars [] _ = []
- removelikechars a b =
- if ((length [y | y <- b, [y] == (take 1 a)]) > 0)
- then
- removelikechars (drop 1 a) b
- else
- (take 1 a) ++ removelikechars (drop 1 a) b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement