Intersecting data question/challenge

Dick Kriesel dick.kriesel at mail.com
Sun Jul 10 02:36:16 EDT 2005


On 7/9/05 2:49 AM, "Buster" <wouter.abraham at scarlet.be> wrote:

> on mouseUp
>    ### filling the data sets
>   ### change by hand or by use a scrollbar
>    repeat 500  --round(thumbpos of sb "A")
>      put random(10000) & cr after A
>    end repeat
>    repeat 200   --round(thumbpos of sb "B")
>      put random(10000) & cr after B
>    end repeat
>    put 0 into time1
>    put 0 into time2
>    put 0 into time3
>    repeat 10
>      put A into x
>      put B into y
>      ### custom prop method
>      put the long seconds into zap
>      set the customkeys of me to x
>      put the customproperties of me into arrA
>      set the customkeys of me to y
>      put the customproperties of me into arrB
>      intersect arrA with arrB
>      put keys(arrA) into tKeys1
>      add the long seconds - zap to time1
>      set the customkeys of me to ""
>      ### replace split method
>      put the long seconds into zap
>      replace cr with tab & cr in x
>      split x with cr and tab
>      replace cr with tab & cr in y
>      split y with cr and tab
>      intersect x with y
>      put keys(y) into tKeys2
>      add the long seconds - zap to time2
>      ### repeat for each + is not among method
>      put A into x
>      put B into y
>      replace cr with comma in x
>      replace cr with comma in y
>      put "" into tList
>      put the long seconds into zap
>      repeat for each item i in x
>        if i is not among the items of y and i is not among the lines
> of tList then put i & cr after tList
>      end repeat
>      add the long seconds - zap to time3
>    end repeat
>    put time1 &cr& time2 & cr & time3
> end mouseUp


The times reported for the second and third methods above are suspect,
because tKeys2 and tList do not match tKeys1.

>      put keys(y) into tKeys2
should be "put keys(x) into tKeys2"

>        if i is not among the items of y
should be "if i is among the items of y"

Also, the time for the second method is overstated, because the code
includes two unnecessary statements:
>      replace cr with tab & cr in x
>      replace cr with tab & cr in y

Despite the inaccuracies, the conclusions remain:
  the first method loses
  the second method wins for long lists
  the third method wins for short lists

Informal testing suggests that the third method wins when the shorter of the
two input lists has around fifty or more lines.  So a general, optimized
handler can choose the method by inspecting the input lists.

Further insights, anyone?

-- Dick





More information about the use-livecode mailing list