‘Super Sub’ multidimensional arrays

Sean Cole (Pi) sean at pidigital.co.uk
Thu Mar 11 03:46:56 EST 2021


Tom
hopefully I’ve set this email not to hijack Harry’s thread.

First thing to note is that LC ONLY structures arrays as tVar[0][0][0]...

But equally we can use, for example, tVar[x][y][z] or tVar[x,y,z] or even
tVar[x,y,z][u,v,w][r,s,t]

However, know that, if x=1, y=“two”, z=true then tVar[x,y,z] is the same as
tVar[“1,two,true”] AND the same as tVar[1,”two”,true].

But this also means that tVar[x,y,z] from the previous paragraph could
equal tVar[tNextVar] if tNextVar=x,y,z AND tNextVar=“1”,”two”,”true” AND
tNextVar=“1,two,true”.

With me so far?

Then let’s now bamboozle.

Repeat for rKey = 1 to 10
        Put rnd(20) into tArraySuperSub[(“key” & rKey)]
End repeat

That’s pretty straight forward. But then...

Repeat for r2ndKey = 1 to 10
        Put tArraySuperSubKey into tArraySub[(“key” & r2ndKey)]
End repeat

And then......

Repeat for r3rdKey = 1 to 10
        Put tArraySub into tArray[(“key” & r3rdKey)]
End repeat

Now place a treeView widget and set its array to tArray and look what an
unholy mess we’ve made.

HERE is the limitation:
You CAN do something like put tArraySub into tArray[x]
But you CANNOT do something like put tArraySuperSub into tArray[tArraySub]
because tArraySub is itself an array.

So, we can nest arrays into other sub arrays to multiple dimensions.

Rabbit hole:

tArray[“pixel”&x,”pixel”&y][“subPixel”&u,”subPixel”&v][“superSubPixel”&r,”superSubPixel”&s]
= tClrR,tClrG,tClrB,tClrA

Could potentially equate to...

tArray[“pixel10,pixel10”][“subPixel7”,”subPixel4”][superSubPixel2,superSubPixel2]

tArray[“pixel10,pixel10”] cannot hold a value without wiping all of its sub
dimensions out of existence and so on through the dimensions down to, in
this scenario, the 3rd (or 6th, depending on you viewpoint) dimension.

Btw, If tArray is an array and tVar is a value you CAN:
put “value” into tArray[tVar]
OR
put tArray into t2ndArray[tVar]
But you CANNOT:
put tVar into t2ndArray[tArray]

Why I say “depending on your viewpoint” above is, thinking
multidimensionally, you could have an array set as x,y,z of space as your
first 3 dimensions, time as a fourth, inside/outside as a fifth,
flipped/reversed as a sixth and so on, represented by perhaps
tArray[x,y,z][t,u,v] or maybe tArray[x][y][z][t][u][v] or even
tArray[x,y,z][t][u][v]

Why is tArray[x,y,z] more useful/flexible but not better than
tArray[x][y][z]?

Good question!


On Thu, 11 Mar 2021 at 03:52, Tom Glod via use-livecode <
use-livecode at lists.runrev.com> wrote:

>  >>>>>> (tArray["key1","key1.1"]["key2","key2.1"])
>
> Sean....  never even thought about this form of arrays.  I gotta test the
> functionality of this.  Thanks.
> I know you are busy, but if you have the time, feel free to blow my mind.



> >
> > That just about covers it. Unless I go into super sub arrays to really
> blow
> > your mind (tArray["key1","key1.1"]["key2","key2.1"])
> >
> > Sean
> > _______________________________________________
> > 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
> >
>
>
> --
> Tom Glod
> Founder & Developer
> MakeShyft R.D.A (www.makeshyft.com)
> Mobile:647.562.9411
> _______________________________________________
> 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
>
-- 
Pi Digital



More information about the use-livecode mailing list