[chuck-users] chuck arguments

N. Cameron Britt nbritt at princeton.edu
Sat Aug 16 13:51:57 EDT 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080816/7316941d/attachment.htm>


More information about the chuck-users mailing list