Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing Duplicates in an Array?
Message
De
03/11/2001 07:01:10
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
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:
00577103
Vues:
18
This message has been marked as the solution 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

Renoir,
I think you want to keep nonsorted :
dimension aNoDupes[1]
aNoDupes=myArray[1]
for ix=2 to alen(myArray,1)
  if ascan(aNoDupes,myArray[ix])=0
     dimension aNoDupes[alen(aNoDupes,1)+1]
     aNoDupes[alen(aNoDupes,1)]=myArray[ix]
  endif
endfor
*asort(aNoDupes) && sorted ?
PS: I didn't go with a cursor way mainly for 2 reasons :
1) Would be slower (sometimes surprisingly not)
2) An array element could hold large amounts of char data
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform