The same designation command to more than one portion of an array
in
Programming Questions
•
1 year ago
I want to designate the same command to more than one portion of an array ie:
pos[0] = random(width - 5,width + 5);
pos[1] = random(width - 5,width + 5);
pos[2] = random(width - 5,width + 5);
pos[3] = random(width - 5,width + 5);
but condense that to write it only once...something like
pos[0-36] = random(width - 5,width + 5);...obviously that method does not work..is there a way to do this though?
I know this can be done for the entire array if I wanted but there are specific parts of the array which require a different command.
pos[0] = random(width - 5,width + 5);
pos[1] = random(width - 5,width + 5);
pos[2] = random(width - 5,width + 5);
pos[3] = random(width - 5,width + 5);
but condense that to write it only once...something like
pos[0-36] = random(width - 5,width + 5);...obviously that method does not work..is there a way to do this though?
I know this can be done for the entire array if I wanted but there are specific parts of the array which require a different command.
1