Subject: Re: Finding non-common elements in two arrays

Bruce A. Pokras wrote:

The intersect function will return the common elements of two arrays. Is there any array methodology that will return the non-common elements of two arrays? I download a government list each month, and I would like an easy way to spot the records that are either new or changed. Currently, I use a repeat structure to go through the old list line-by-line to see if any lines are not identically found in the new list (using offset), and collect a third list of any lines in which offset=0. After splitting the old and new lists into arrays, an "inverse-intersect" function or equivalent would seem to be a more elegant way of doing this.

Any ideas?


Thanks for everyone's the suggestions. I put Alex Tweedly's array script (see below) to the test against a line-by-line "offset" script ("repeat for each line n in list1" etc.). The lists were text files representing two consectutive months of a 20,000 line government database with 11 fields per line. The idea is to see which records in the new list have been added to or changed from the previous list.

There was simply no comparison between the methods. It took all of 18-19 seconds to make the comparison using Alex's method (I ran it twice to make sure I wasn't imagining it). Using the line-by-line offset method, it took 14 minutes! A comparison in MS Word of the results of each method showed them to be identical.

I never would have believed that the first steps of going through each list and creating complete copies of them with the tab & 1 or 2 could occur so quickly. The incredible speed of those two steps (creating two new 20,000 line lists) is really what makes this thing work.

I will next check out Wouter's more sophisticated version, since I may have a use for the additional functionality of that one, also.

Thanks very much Alex and Wouter, and thanks to everyone else who repsonded to my question.

Regards,

Bruce Pokras
Blazing Dawn Software
www.blazingdawn.com


on mouseUp
put fld "F1" into t1
    repeat for each line L in t1
        put L & TAB & "1" & cr after tA1
    end repeat
    split tA1 by CR and TAB
put fld "F2" into t1
    repeat for each line L in t1
        put L & TAB & "2" & cr after tA2
    end repeat
    split tA2 by CR and TAB
union tA1 with tA2
    combine tA1 with CR and TAB
      filter tA1 with ("*"&TAB&"2")
      put tA1 into fld F3

end mouseUp



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

Reply via email to