Finding non-common elements in two arrays

Jim Ault JimAultWins at yahoo.com
Sun Nov 6 15:10:13 EST 2005


>I download a government list each month...snip
>>     get lineoffset(i,f2)
One catch I can see is the "set whole matches to true"
also considering the false hits generated by your definition of a unique
line (lower case, sub string, number format)
 "Mary had a little lamb" = line 6 of field 2
"Mary had a little lamb,  whose fleece was white" = line 8 of field 1
line 6 of fld 2 is in line 8 of fld 1 => lineoffset would be > 0

"234" & "2345" == offset match, lineOffset not
"234" & "2,345" == offset match not,  lineOffset not
"234" & "2345.00 == offset match, lineOffset not
"234" & "2345, 554, 234, 196" == lineoffset match twice
"snow"  & "snow shovel" & "snowbound" & "snow-bound"

Jim Ault
Las Vegas

On 11/6/05 5:49 AM, "Alex Tweedly" <alex at tweedly.net> wrote:

> Buster wrote:
> 
>> 
>> On 06 Nov 2005, at 01:39, Alex Tweedly wrote:
>> Hi,
>> This method is reporting the missing lines of field 1 in field 2 and
>> not the unique lines in both.
> 
> That's right - that's how I interpreted the original request. It said
> "... spot the records that are either new or changed". It didn't say "or
> deleted".  Wanting both is probably a more reasonable interpretation.
> The second version I sent last night does produce both results, though I
> commented out the  part that I thought wasn't needed.
> 
>> This does:
>> 
>> on mouseUp
>>   put fld 2 into f2
>>   repeat for each line i in fld 1
>>     get lineoffset(i,f2)
>>     if it = 0 then put i & cr after tList
>>     else delete line it of f2
>>   end repeat
>>   put tList & f2 into fld 3
>> end mouseUp
> 
> Nice clean simple code, but a bit slow.
> The "loop" version I sent in my later mail is a bit faster, esp. on
> larger data sets, but unless that's a big problem, I personally would
> stick to this simple code.
> 
> Even if Rev does the enhancement Ken requested in BZ, it still won't
> provide a clean way to solve this problem (because it operates on the
> keys of the array, so you need to do the ugly append to each line then
> split ....)





More information about the use-livecode mailing list