[Gambas-user] Get distinct array from large array

Martín Belmonte mbelmonte at belmotek.net
Fri Dec 10 09:15:01 CET 2021


El 10/12/21 a las 4:53, Safiur Rahman escribió:
> Dim yyy As String[]
>    Dim xx As String
> 
>    yyy = New String[]
>    For Each xx In xxx
>      If yyy.Count = 0 Then
>        yyy.Add(xx)
>      Else If yyy.Count > 0 Then
>        If yyy.Find(xx, gb.Binary) = -1 Then
>          yyy.Add(xx)
>        Endif
>      Endif
>    Next

I propose this

'' Returns an array of data without repetitions and as input parameter 
requires another array.

Static Public Function aUnique(aList As String[]) As String[]

   Dim s As String
   Dim aOut As New String[]

   For Each s In aList
     If aOut.Exist(s) = False Then
       aOut.Add(s)
     Endif
   Next

   Return aOut

End




More information about the User mailing list