{- COMP2600 Assignment 1 Joseph Curtis 3952239 -} elemSort :: Ord a => a -> [a] -> Bool elemSort y [] = False -- if the list is empty then it obviously -- does not contain y so it is false. elemSort y (x:xs) | y == x = True -- if x = y then the search has found -- the element and so it is true. | x > y = False -- if the search has gone beyond -- the desired item, sinced it is -- sorted it must not be in there. | otherwise = elemSort y xs -- if none of these things happen then -- keep on searching. remDups :: Ord a => [a] -> [a] remDups [] = [] remDups (x:xs) | null xs = x:[] | x == head xs = (remDups (tail (x:xs))) -- if two adjacent elements are the same -- then the value returned is simply the -- same list without the first element | otherwise = x:(remDups xs) -- if two adjacent elements are not the -- same then x is joined with the recursive -- call on remDups with the rest of the -- list (apart from x)