Consider this implementation
noDupes : List a -> List a noDupes list = case list of [] -> [] [ a ] -> [ a ] a :: b :: more -> if a == b then noDupes (a :: more) else a :: noDupes (b :: more)
When we test it
noDupes [1, 1, 2, 2, 3, 3, 3, 4, 5, 4, 4, 4, 4] -- [ 1, 2, 3, 4, 5, 4 ] : List number noDupes ["a", "b", "b", "c", "c", "c", "d", "d", "c" ] -- [ "a", "b", "c", "d", "c" ] : List String
I had this noDupes (a :: more) in the else branch when experimented with the code but didn't consider putting that in the first branch.
Thank you. I appreciate your help.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Consider this implementation
When we test it
I had this noDupes (a :: more) in the else branch when experimented with the code but didn't consider putting that in the first branch.
Thank you. I appreciate your help.