Fix the same modulo bug in arp and slowcatPrime

This commit is contained in:
Tijmen Zwaan
2026-08-04 18:03:12 +02:00
parent 429682735d
commit eafa2f17ec
+2 -2
View File
@@ -1002,7 +1002,7 @@ export const arpWith = register('arpWith', (func, pat) => {
* */
export const arp = register(
'arp',
(indices, pat) => pat.arpWith((haps) => reify(indices).fmap((i) => haps[i % haps.length])),
(indices, pat) => pat.arpWith((haps) => reify(indices).fmap((i) => haps[_mod(i, haps.length)])),
false,
);
@@ -1559,7 +1559,7 @@ export function slowcat(...pats) {
export function slowcatPrime(...pats) {
pats = pats.map(reify);
const query = function (state) {
const pat_n = Math.floor(state.span.begin) % pats.length;
const pat_n = _mod(Math.floor(state.span.begin), pats.length);
const pat = pats[pat_n]; // can be undefined for same cases e.g. /#cHVyZSg0MikKICAuZXZlcnkoMyxhZGQoNykpCiAgLmxhdGUoLjUp
return pat?.query(state) || [];
};