Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing Duplicates in an Array?
Message
De
02/11/2001 16:12:57
 
 
À
02/11/2001 16:00:51
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00576991
Message ID:
00577001
Vues:
15
This message has been marked as a message which has helped to the initial question of the thread.
>Any simple way to remove duplicates in a one dimensional array? No specific order to the rows and the elements are text. I'm thinking of looping through, and comparing elements, but the no-order thing has got me paused... Thanks!
>
>Regards, Renoir

See if this works.

Jay
#DEFINE   EMPTY_CELL    "This phrase will never happen"

FOR X = 1 TO ALEN (aDupes, 1)
   IF aDupes [X] <> EMPTY_CELL
      FOR Y = X TO ALEN (aDupes, 1)
         IF aDupes [X] = aDupes [Y]
            aDupes[Y] = EMPTY_CELL
         ENDIF
      ENDFOR
   ENDIF
ENDFOR

FOR X = ALEN (aDupes, 1) TO 1 STEP -1
    IF aDupes[X] = EMPTY_CELL
        ADEL [X]
    ENDIF
ENDFOR

*  Then redimension based on the last non empty cell.
  
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform