{- Remove Duplicates Function CSci 450/503, Fall 2016 2016-11-26: H. Conrad Cunningham -} import Html exposing (..) -- Function remdups takes a list of comparable values and returns the -- list resulting from the removal of adjacent duplicates. Type -- variable comparable is restricted to values that can be compared. remdups : List comparable -> List comparable -- remdups : List Int -> List Int remdups xs = case xs of x::y::ys -> if x == y then remdups (y :: ys) else x :: remdups (y :: ys) _ -> xs -- Simple Display Functions newline = br [] [] displayLines : List String -> List (Html msg) displayLines ss = case ss of [] -> [] x :: xs -> text x :: newline :: displayLines xs display : List String -> Html msg display ls = p [] (displayLines ls) -- Some testing test1 = remdups [] test2 = remdups [1] test3 = remdups [1,1] test4 = remdups [1,2] test5 = remdups [1,2,3] test6 = remdups [1,2,2] test7 = remdups [1,2,3,3,3] test8 = remdups [1,1,1,2,3,3,3,3,4,5,5,5,5,6] main = display [ "remdups tests:" , toString test1 , toString test2 , toString test3 , toString test4 , toString test5 , toString test6 , toString test7 , toString test8 , "End!" ]