Renato, If you know the sizes of your vectors you could simply pass the elements of your vectors as separate arguments and populate the various arrays in chuck. The following makes two arrays -- one with two elements, one with three: chuck test.ck:1:2:3:4:5 test.ck as follows: int vect1[2]; int vect2[3]; for( 0 => int i; i < me.args(); i++) { //fill vect1 if(i == 0) { for( 0 => int i; i < vect1.cap(); i++) { Std.atoi(me.arg(i)) => vect1[i]; } } //fill vect2 if(i == 2) { for( 0 => int i; i < vect2.cap(); i++) { Std.atoi(me.arg(i+2)) => vect2[i]; } } } for(0 => int i; i < vect1.cap(); i++) { <<<"vect1", vect1[i]>>>; } for(0 => int i; i < vect2.cap(); i++) { <<<"vect2", vect2[i]>>>; } test.ck outputs: vect1 1 vect1 2 vect2 3 vect2 4 vect2 5
thanks for the approach :o). but i dont know the size of the vectors and i dont know the number of vectors in each of the two sets of vectors. (to be used in different stuff). i know the number of first n string arguments. so, when i start the vector (all integers) part of argument, i intend using some two special integer tags (say 999 and 9999) to delineate each vector and each set of vectors. i think it works as ChucK reises an error in trying to compare string and integers, but it can convert numeric strings (as numeric arguments are understood) to integers and compare integers. i try it out soon.
chuck test.ck:1:2:3:4:5
test.ck as follows:
int vect1[2]; int vect2[3];
for( 0 => int i; i < me.args(); i++) { //fill vect1 if(i == 0) { for( 0 => int i; i < vect1.cap(); i++) { Std.atoi(me.arg(i)) => vect1[i]; } }
//fill vect2 if(i == 2) { for( 0 => int i; i < vect2.cap(); i++) { Std.atoi(me.arg(i+2)) => vect2[i]; } }
}
for(0 => int i; i < vect1.cap(); i++) { <<<"vect1", vect1[i]>>>; }
for(0 => int i; i < vect2.cap(); i++) { <<<"vect2", vect2[i]>>>; }
test.ck outputs: vect1 1 vect1 2 vect2 3 vect2 4 vect2 5
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (2)
-
N. Cameron Britt
-
Renato Fabbri