Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing Duplicates in an Array?
Message
From
03/11/2001 07:01:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
02/11/2001 16:00:51
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00576991
Message ID:
00577103
Views:
19
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform