Hi again,

A little update on the intersectSpecial function
--> a bit speedier and 3 results in 1 array

function intersectSpecial pListA,pListB,@pR
  if char -1 of pListA is not cr then put cr after pListA
  replace cr with tab & "1" & cr in pListA
  split pListA with cr and tab
  repeat for each line i in pListB
    add 2 to pListA[i]
  end repeat
  repeat for each line i in the keys of pListA
    put i & cr after pR[pListA[i]]
  end repeat
  return the keys of pR <> ""
end intersectSpecial

on mouseUp
  put the millisecs into zap
  get intersectSpecial(fld 1,fld 2,a)
  put the millisecs - zap
  if it then
    put "* Common in both:" & cr & a[3] after tList
    put "* Unique in list A:" & cr & a[1] after tList
    put "* Unique in list B:" & cr & a[2] after tList
    put tList into fld 3
  else put it into fld 3
end mouseUp


Greetings,
Wouter



On 07 Nov 2005, at 01:05, Buster wrote:

function intersectSpecial pList1,pList2,pMode
  repeat for each line i in pList1
    add 1 to a[i]
  end repeat
  repeat for each line i in pList2
    add 2 to a[i]
  end repeat
  combine a with cr and tab
### elements only in pList1 --> 1
### elements only in pList2 --> 2
### elements in both lists     --> 3
  if pMode = "bothCommon" then put "*"&tab&"3" into tFilter
  else  if pMode = "uniqueA" then put "*"&tab&"1" into tFilter
  else if pMode = "uniqueB" then put "*"&tab&"2" into tFilter
else if pMode = "bothUnique" then put "*"&tab&"1,*" &tab&"2" into tFilter
  repeat for each item tFilterString in tFilter
    put a into b
    filter b with tFilterString
    replace char 2 to -1 of tFilterString with "" in b
    put b & cr after tList
  end repeat
  return tList
end intersectSpecial

on mouseUp
  put the millisecs into zap
  put intersectSpecial(fld 1,fld 2,"bothUnique") into fld 3
  put the millisecs - zap
end mouseUp

May be not a real speed monster but not bad either
(takes < 500 millisecs for 2 fields with > 25000 lines on an iMac G5 1.8 gHz)

Greetings,
Wouter
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to