Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input :: [String]
- input = [
- "billowy",
- "biopsy",
- "chinos",
- "defaced",
- "chintz",
- "sponged",
- "bijoux",
- "abhors",
- "fiddle",
- "begins",
- "chimps",
- "wronged"]
- isSorted :: (a -> a -> Bool) -> [a] -> Bool
- isSorted cmp xs = and $ zipWith cmp xs (tail xs)
- solve :: String -> String
- solve xs
- | isSorted asc xs = xs ++ " IN ORDER"
- | isSorted desc xs = xs ++ " REVERSE ORDER"
- | otherwise = xs ++ " NOT IN ORDER"
- where asc = (<=)
- desc = (>=)
- main :: IO ()
- main = mapM_ (putStrLn . solve) input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement