Quickest was to compare 2 CR lists?
Mark Smith
lists at futilism.com
Tue Nov 4 06:47:32 EST 2008
I hadn't realised we have an array intersect command!
split k1 by cr and numtochar(4)
split k2 by cr and numtochar(4)
intersect k1 with k2
return keys(k1)
best,
Mark
On 4 Nov 2008, at 11:04, Mark Smith wrote:
> A little benchmarking...
>
> Brian's is the fastest because building the array with a repeat for
> each loop is faster (just about 2x) than my fooling around with
> adding delimiters and then split-ting into an array (which should
> not use comma, anyway)
>
>
> Best,
>
> Mark
>
> On 4 Nov 2008, at 10:33, Mark Smith wrote:
>
>> Here's mine...
>>
>> function listIntersect list1, list2
>> replace cr with comma & "1" & cr in list1
>> split list1 by cr and comma
>>
>> repeat for each line L in list2
>> if list1[L] is not empty then put L & cr after tIntersect
>> end repeat
>> return tIntersect
>> end listIntersect
>>
>> This seems a bit faster (20-30%) than the repeat for each
>> approach. and for long lists with many duplicates it'll probably
>> be faster still.
>>
>> best,
>>
>> Mark
>>
>>
>> On 4 Nov 2008, at 09:08, Klaus Major wrote:
>>
>>> Hi all,
>>>
>>> anyone knows the quickest ways to compare 2 CR delimited lists?
>>> I need to know what lines of list 1 are contained in list 2.
>>>
>>> Right now I am using repeat "for each" and "lineoffset", which is
>>> fast,
>>> but I'm ure this can be done even faster :-)
>>>
>>> List 1 = k1
>>> List 2 = k2
>>>
>>> ...
>>> repeat for each line i in k1
>>> if lineoffset(i,k2) <> 0 then
>>> put i & CR after new_ list
>>> end if
>>> end repeat
>>> delete char -1 of new_ list
>>> return new_ list
>>> ...
>>>
>>>
>>> Best
>>>
>>> Klaus Major
>>> klaus at major-k.de
>>> http://www.major-k.de
>>>
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list