Page 1 of 1

array

Posted: 15 Jan 2014 23:15
by 221180
Hello,
I'm looking to create a vector of vector.

exemple:

Tab.0={0,0,0};
Tab.1={0,0,1};
Tab.2={0,1,0};
Tab.3={0,1,1};

what I want to do:

decl val;
TAB[0]=Tab.0;
val=TAB[0];

*/val={0,0,1} /*

If you could help me to manage "array of array" or "vector of vector" would be very nice;)
Regards,

Re: array

Posted: 15 Jan 2014 23:53
by Softcore
TABALL={TAB.0, TAB.1,TAB.2,TAB.3}

then

decl val=TABALL[0] will be val = 0 NOT val = TAB.0

BUT you can go

decl val=subarray(TABALL,0,3) which will give you {0,0,0} (i.e. TAB.0)

By using sizeof(TAB.0) you can easily know where to split TABALL to get the individual arrays that formed it dynamically

Re: array

Posted: 16 Jan 2014 11:47
by oldgearguy
221180 wrote:Hello,
I'm looking to create a vector of vector.

exemple:

Tab.0={0,0,0};
Tab.1={0,0,1};
Tab.2={0,1,0};
Tab.3={0,1,1};

what I want to do:

decl val;
TAB[0]=Tab.0;
val=TAB[0];

*/val={0,0,1} /*

If you could help me to manage "array of array" or "vector of vector" would be very nice;)
Regards,

I've been doing something like this. The way I got it to work was that instead of declaring Tab0, Tab1, etc as variables, I declare them as Monitor objects and set Tab2.value = {0,1,0}

then by using a variable like TABALL = {Tab0, Tab1, Tab2} you can say val = TABALL[2] and get val = Tab2. To get the original vector {0,1,0}, use val.value. The TABALL array effectively contains references to the objects and not the object contents, so you can use the reference to retrieve the contents. I'm not exactly sure if the Lemur code was intended to work this way. Doing more complex operations with these structures has caused me some headscratching and some WTF moments for sure.

Re: array

Posted: 16 Jan 2014 12:06
by Softcore
Also, forgot to mention this way

decl obj={TAB.0,TAB.1,TAB.2,TAB.3};

decl val=getexpression(obj[0],'x');

then val={0,0,0} (i.e. TAB.0)

Re: array

Posted: 18 Jan 2014 19:08
by 221180
Thanks Softcore and oldgearguy, that's works!

Re: array

Posted: 19 Jan 2014 08:54
by 221180
Ok after some experimentation I understand that the notion of more than 1D array doesn't work.

Using VECTORALL[j]={vect0, vect1, vect2, ect..} simply create a single vector with concatenation of vect0, vect1,vect2, etc... starting at j.

The way to manage this collection is the subarray(obj, start, length).

So my wish for the next update of lemur is to be able to use 2D or 3D array or vector ;)

Regards,

Re: array

Posted: 19 Jan 2014 10:15
by 221180
I use a 17 note KEYBOARD
I have 16 Steps and 16 Paternes
This script show how to record my notes in regards to the steps and the Paternes


//NOTES//
decl i;
i=firstof(KEYBOARD.Steps.x);
decl j;
j=firstof(Paternes.x);

if(KEYBOARD.note0.x==1) Notes[i+(j*17)]=0;
else if(KEYBOARD.note1.x==1) Notes[i+(j*17)]=1;
else if(KEYBOARD.note2.x==1) Notes[i+(j*17)]=2;
else if(KEYBOARD.note3.x==1) Notes[i+(j*17)]=3;
else if(KEYBOARD.note4.x==1) Notes[i+(j*17)]=4;
else if(KEYBOARD.note5.x==1) Notes[i+(j*17)]=5;
else if(KEYBOARD.note6.x==1) Notes[i+(j*17)]=6;
else if(KEYBOARD.note7.x==1) Notes[i+(j*17)]=7;
else if(KEYBOARD.note8.x==1) Notes[i+(j*17)]=8;
else if(KEYBOARD.note9.x==1) Notes[i+(j*17)]=9;
else if(KEYBOARD.note10.x==1) Notes[i+(j*17)]=10;
else if(KEYBOARD.note11.x==1) Notes[i+(j*17)]=11;
else if(KEYBOARD.note12.x==1) Notes[i+(j*17)]=12;
else if(KEYBOARD.note13.x==1) Notes[i+(j*17)]=13;
else if(KEYBOARD.note14.x==1) Notes[i+(j*17)]=14;
else if(KEYBOARD.note15.x==1) Notes[i+(j*17)]=15;
else if(KEYBOARD.note16.x==1) Notes[i+(j*17)]=16;

So if I would like to get the 16 notes of the paternes 2 (start to 0) :

decl val;
val=subarray(Notes,34,50);

That return me a vector of the 16 notes of the paternes 2.

etc...