Finding non-common elements in two arrays
Alex Tweedly
alex at tweedly.net
Sat Nov 5 19:39:32 EST 2005
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?
It's a bit of a faff, so it's arguably not elegant at all, and you'd
need to do some testing to see if it's faster or not.
(Oh - and the final result still needs cleaning up ....)
> 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
>
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.8/161 - Release Date: 03/11/2005
More information about the use-livecode
mailing list