Make a subroutine that removes duplicates from a list. If the list is passed as an array, then return a clean list. If the list is passed as a reference to an array then clean the given array in place.