Something is bothering me with my code, extremely, and I can’t figure out why is this happening. Look at the outputs below the code please
(
~arrWithSmallestMaxNum = {
arg arrs;
arrs.minItem({arg a, i; a.maxItem})
};
~getArrIdx = {
arg arrs, arr;
var idx = -1;
block {
arg breakfun;
arrs.do {
arg a;
idx = idx + 1;
if (a == arr) {breakfun.value(idx)};
};
nil
}
};
~maxCommonN = {
arg arrs, isInAll;
var smaxArr = ~arrWithSmallestMaxNum.(arrs);
var idxToRm = ~getArrIdx.(arrs, smaxArr);
// Modify arrs
if (idxToRm != nil) {arrs.removeAt(idxToRm)};
block {
arg break;
smaxArr[1..].do {
arg n;
isInAll = true;
arrs.do {
arg arr;
arr = arr[1..];
arr.do{
arg a;
[arr, a, n, (a == n)].postln;
};
if (arr.includes(n).not) {isInAll = false}
};
if (isInAll) {break.value(n)};
};
nil
}
};
)
Now calling it:
(
~maxCommonN.([
Array.series(5, 0, 3/5),
Array.series(5, 0, 4/5)
]);
)
outputs:
[ [ 0.8, 1.6, 2.4, 3.2 ], 0.8, 0.6, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 1.6, 0.6, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 2.4, 0.6, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 3.2, 0.6, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 0.8, 1.2, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 1.6, 1.2, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 2.4, 1.2, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 3.2, 1.2, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 0.8, 1.8, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 1.6, 1.8, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 2.4, 1.8, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 3.2, 1.8, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 0.8, 2.4, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 1.6, 2.4, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 2.4, 2.4, false ]
[ [ 0.8, 1.6, 2.4, 3.2 ], 3.2, 2.4, false ]
In the line before the last line, a
and n
are both 2.4 and I asked whether a == n
, with the result being false
! Also a === n
returns false
. Why is this happening. I can’t see it in the code. Any help is appreciated.