There is something wrong. Please compare the results of:
seq4_1_20 = first_function(4, 20);
with the same call from your earlier code…
int[] seq4_1_20, seqNeg4_1_20, seq1_10_Neg10;
int lo, dir;
void setup() {
seq4_1_20 = first_function(4, 20);
seqNeg4_1_20 = first_function(4, -20);
seq1_10_Neg10 = second_function(-1, 10, -10);
println(seq4_1_20);
println();
//println(seqNeg4_1_20);
println();
//println(seq1_10_Neg10);
exit();
}
int[] first_function(int n, int hi) {
if (hi >= 0) {
lo = 1;
} else {
lo = -1;
}
return second_function(n, lo, hi);
}
int[] second_function(int n, int lo, int hi) {
int qty = abs(hi - lo) + 1;
int len = abs(n) * qty;
if (hi >= lo) {
dir = 1;
} else {
dir = -1;
}
int seq[] = new int[len];
for (int i = 0; i < len; i++) {
seq[i] = i % qty * dir + lo;
}
return seq;
}