Nested array comparisons

Mark Schonewille m.schonewille at economy-x-talk.com
Sun Mar 24 20:17:04 EDT 2013


Ok thanks for testimg. That's very useful to know. I must say I'm curious to find out more about the peculiarities of arrays now.

--
Kind regards,

Mark Schonewille
Economy-x-Talk
Http://economy-x-talk.com

Share the clipboard of your computer over a local network with Clipboard Link http://clipboardlink.economy-x-talk.com


Op 25 mrt. 2013 om 00:57 heeft Alex Tweedly <alex at tweedly.net> het volgende geschreven:

> 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
> 
> 
> _______________________________________________
> 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