So I have this function...
removeDuplicate :: [CustomType] -> [CustomType]
removeDuplicate [] = []
removeDuplicate [x] = [x]
removeDuplicate [x, y] =
if x==y then [x]
else [x, y]
removeDuplicate (x:y:xs) =
if x==y
then removeDuplicate ([x] ++ xs)
else removeDuplicate ([y] ++ xs ++ [x])
Here, I have to check if there is an element in the array(sorted) which is equal to other elements in the array.
I am unable to work on a termination condition for this function. It just goes into an infinite loop over here.
Normally, I could have used a visited array or count for this kind of situation but I'm new to Haskell and I am not sure what is the way to handle this situation.
P.S. Please let me know if any other details are needed.