Nested array comparisons

Alex Tweedly alex at tweedly.net
Sun Mar 24 19:57:33 EDT 2013


Sorry - the copy/paste of the result included some binary characters, so 
the email was incomplete ....

try it yourself if you want to see the details - but the bottom line is 
that the arrays have the same keys and contents, comparing the arrays 
gets that right, and comparing the arrayencode() of the arrays says 
(wrongly) that they differ.

QED - you can't compare the arrayencoding, even in some simple cases.

-- Alex.


On 24/03/2013 23:53, Alex Tweedly wrote:
> OK, let's just test it - focusing on the likelihood that key order 
> matters
>
> Code:
>> on mouseup
>>    local T1, T2
>>    local tK, j
>>
>>    constant K = 10
>>    repeat with i = 1 to K
>>       put random(i) into t1[i]
>>    end repeat
>>
>>    put the keys of T1 into tK
>>    repeat with i = K down to 1
>>       put line i of tK into j
>>       put T1[j] into T2[j]
>>    end repeat
>>
>>    put "array" && (T1 = T2) & CR &  "code" && (arrayencode(t1) is 
>> arrayencode(t2)) \
>>    &CR & arrayencode(t1) &CR&CR & arrayencode(t2)
>> end mouseup
> Result:
>> array true
>> code false
>> 
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list