Need help with Removing Duplicates from Array
Steven Schveighoffer
schveiguy at gmail.com
Tue Jun 27 12:31:27 UTC 2023
On 6/27/23 8:13 AM, sonal13 wrote:
> Hey everyone,
>
> I've been encountering some trouble while trying to remove duplicates
> from an array, and I was hoping someone could help me out. I came across
> a tutorial that explains how to remove duplicates from an array. Here's
> the [Remove Duplicates from Array
> Tutorial](https://www.interviewbit.com/blog/remove-duplicates-from-array/).
>
> I followed the steps outlined in the tutorial, but I seem to be getting
> unexpected results. Instead of removing duplicates, the array remains
> unchanged. I'm not sure what I'm doing wrong here.
>
> Here's the code snippet I'm using:
>
> ```python
> def remove_duplicates(arr):
> unique_array = list(set(arr))
> return unique_array
> ```
This is a D forum, not python.
So while you might find help here, it likely will be in the form of D code.
This also is not the learn forum, please use that if you have further
questions about D.
How I'd do it:
```d
arr = arr.sort.uniq.array;
```
-Steve
More information about the Digitalmars-d
mailing list