Excellent! But how come you can have:
This does not work for me. How can I get just the sequence as you have it and not:
[0] 3
[1] 5
[2] 7
[3] 9
[4] 3
[5] 5
[6] 7
[7] 9
int[] testsequence;
// first parameter is number of repetitions
// second parameter is lo
// third parameter is hi
// fourth parameter is step
void setup() {
testsequence = int_series_repeated(2, 3, 9, 2);
//println(testsequence);
exit();
}
int[] int_series_repeated(int n, int lo, int hi, int step) {
int inc;
if (step != 0) {
inc = abs(step);
} else {
inc = 1;
}
int dir;
if (lo < hi) {
dir = 1 * inc;
} else {
dir = -1 * inc;
}
int qty = abs(hi - lo)/ inc + 1;
int len = abs(n) * qty;
int seq[] = new int[len];
for (int i = 0; i < len; i++) {
seq[i] = i % qty * dir + lo;
println(seq[i]); // here during testing
}
return seq;
}