deleteDups() [a bit OT]

Eric Chatonet eric.chatonet at sosmartsoftware.com
Wed Nov 16 14:02:28 EST 2005


Hi all,

I would like only to point out the beauty of XTalks languages: you  
have always many ways to do a thing.
Some can be verbose, difficult to read, not optimised but work.
Other are more elegant, shorter and/or faster.
In all cases, I would call that creativity :-)
That's one of the reasons why this list is so much friendly and  
reactive.

Best Regards from Paris,

Eric Chatonet.

PS. Jacque, I love your solution...
As usual, women come immediately to essential ;-)

Le 16 nov. 05 à 17:24, Geoff Canyon a écrit :

>
> On Nov 16, 2005, at 7:29 AM, HyperChris at aol.com wrote:
>
>> Chris wrote:
>> function deleteDups pList
>>     repeat with x=number of lines in pList down to 2
>>     if line x of pList is line (x-1) of pList then delete line x  
>> of pList
>>     end repeat
>>   return pList
>> end deleteDups
>>
>> then Eric Chatonet wrote ...
>> function deleteDups pList
>>   local tLine,tStrippedList
>>   -----
>>   repeat for each line tLine in pList
>>      if tLine is not among the lines of tStrippedList
>>      then put tLine & cr after tStrippedList
>>    end repeat
>>   return word 1 to -1 of tStrippedList
>> end deleteDups
>>
>> then J. Landman Gay wrote ...
>> function deleteDups pList
>>    split pList by cr and numToChar(3)
>>    return keys(pList)
>> end deleteDups
>>
>>
>> You have enlarged my universe. Using "for each" is several orders of
>> magnitude faster than my original script and "split" is faster still.
>
> Bother -- it happened again. First we had repeat for each turning  
> up faster than the filter command. Now I've done a test on the  
> following, and it looks like the split command takes not quite  
> twice as long as repeat for each (when repeat for each is handled  
> the following way).
>
> function deleteDupes pList -- does _not_ retain sort order
>   repeat for each line L in pList
>     put 1 into temp[L]
>   end repeat
>   return the keys of temp
> end deleteDupes

----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------




More information about the Use-livecode mailing list