Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-07-01 Thread nando_f
there are much faster ways...just a little more intricate. Nando -- Open WebMail Project (http://openwebmail.org) -- Original Message --- From: Fernando Cabral To: mailing list for gambas users Sent: Sat, 1 Jul 2017 00:18:42 -0300 Subject: Re: [Gambas-user] I need a hint on

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Fernando Cabral
I thank you guys for the hints on counting and eliminating duplicates. In the end, I resorted to something that is very simple and does the trick in three steps. In the first step I sort the array. In the second step I count the number of occurrences and prepend it to the word itself (with a separa

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Gianluigi
Just for curiosity, on my computer, my function (double) processes 10 million strings (first and last name) in about 3 seconds. Very naif measurement using Timers and a limited number of names and surnames eg Willy Weber has come up 11051 times To demonstrate the goodness of Tobias' arguments, abo

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Gianluigi
Sorry Tobias, other explanations are not necessary. I would not be able to understand :-( I accept what you already explained to me as a dogma and I will try to put it into practice by copying your code :-). Thanks again. Gianluigi 2017-06-30 17:44 GMT+02:00 Gianluigi : > > 2017-06-30 17:21 GMT

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Gianluigi
2017-06-30 17:21 GMT+02:00 Tobias Boege : > > I wouldn't say there is anything *wrong* with it, but it also has quadratic > worst-case running time. You use String[].Push() which is just another name > for String[].Add(). Adding an element to an array (the straightforward way) > is done by extendi

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Tobias Boege
On Fri, 30 Jun 2017, Gianluigi wrote: > What was wrong in my example which meant this? > > Public Sub Main() > > Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E", > "E", "E", "F"] > Dim s As String > > For Each s In ReturnArrays(sSort, 0) > Print s > Next > For

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Gianluigi
What was wrong in my example which meant this? Public Sub Main() Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E", "E", "E", "F"] Dim s As String For Each s In ReturnArrays(sSort, 0) Print s Next For Each s In ReturnArrays(sSort, -1) Print s Next End Pri

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Tobias Boege
On Fri, 30 Jun 2017, Fernando Cabral wrote: > 2017-06-30 7:44 GMT-03:00 Fabien Bodard : > > > The best way is the nando one ... at least for gambas. > > > > As you have not to matter about what is the index value or the order, > > the walk ahead option is the better. > > > > > > Then Fernando ...

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread ML
On 30/06/17 08:20, Fernando Cabral wrote: > 2017-06-30 7:44 GMT-03:00 Fabien Bodard : >> The best way is the nando one ... at least for gambas. >> As you have not to matter about what is the index value or the order, >> the walk ahead option is the better. >> Then Fernando ... for big, big things..

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Fernando Cabral
; > Next > >> > > >> > 'if you want it sorted, do it here > >> > Return z > >> > > >> > END > >> > > >> > ' - - - - - > >> > use it this way: > >> > > >> > myArray = Remo

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Fabien Bodard
> Return z >> > >> > END >> > >> > ' - - - - - >> > use it this way: >> > >> > myArray = RemoveMultiple(myArray) >> > 'the z array is now myArray. >> > 'the original array is destroyed because there a

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
mple would be: > > > > > > > > You have your array with data > > > > You create a new empty array. > > > > > > > > Loop through each item in your array with data > > > > If it's not in the new array, then add it. >

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Jussi Lahtinen
s destroyed because there are no references. > > > > -- > Open WebMail Project (http://openwebmail.org) > > > -- Original Message --- > From: Gianluigi > To: mailing list for gambas users > Sent: Tue, 27 Jun 2017 16:52:48 +0200 > Subject: Re: [Gambas-user

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
age ------- > From: Gianluigi > To: mailing list for gambas users > Sent: Tue, 27 Jun 2017 16:52:48 +0200 > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items > in a array > > > My two cents. > > > > Public Sub Main() > > >

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote: > So, my question is basically if Gambas has some built in method do > eliminate duplicates. > The reason I am asking this is because I am new to Gambas, so I have found > myself coding > things that were not needed. For instance, I coded some functions t

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
2017-06-27 11:29 GMT-03:00 Tobias Boege : > > Your first sentence is a bit confusing. First you say that your array is > sorted but then you say that duplicates may be scattered across the array. > You are right. My fault. The array is sorted. What I meant by scattered was that pairs, duples, trip

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread nando_f
Message --- From: Gianluigi To: mailing list for gambas users Sent: Tue, 27 Jun 2017 16:52:48 +0200 Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array > My two cents. > > Public Sub Main() > > Dim sSort As String[] = ["A",

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Gianluigi
[] > > Dim x as Integer > Dim z as NEW STRING[] > > For x = 1 to a.count() > if z.Find(a) = 0 Then z.Add(a[x]) > Next > > Return z > > END > > -Nando (Canada) > > > > > -- > Open WebMail Project (http://openwebmail.org) > >

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread nando_f
From: Hans Lehmann To: gambas-user@lists.sourceforge.net Sent: Tue, 27 Jun 2017 15:51:19 +0200 Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array > Hello, > > loo

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote: > Hi > > I have a sorted array that may contain several repeated items scattered all > over. > > I have to do two different things at different times: > a) Eliminate the duplicates leaving a single specimen from each repeated > item; > b) Eliminate the

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Hans Lehmann
Hello, look here: 8<- Public Function RemoveMultiple(aStringListe As String[]) As String[] Dim iCount As Integer Dim iIndex As Integer Dim sElement As String iIndex = 0 ' Initialisierung NICHT notwen