diff --git a/src/builtins/group.c b/src/builtins/group.c index 866485ab..d96b8a3c 100644 --- a/src/builtins/group.c +++ b/src/builtins/group.c @@ -298,11 +298,12 @@ B group_c2(B t, B w, B x) { Arr* r = m_fillarr0p(ria); B xf = getFillQ(x); + incBy(xf, ria); B* rp = fillarr_ptr(r); for (usz i = 0; i < ria; i++) { Arr* c = m_fillarrp(len[i]); c->ia = 0; - fillarr_setFill(c, inc(xf)); + fillarr_setFill(c, xf); NOGC_E; // see comments in group_simple arr_shVec(c); rp[i] = taga(c); diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index d4901ab9..27435215 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -757,7 +757,7 @@ B join_c1(B t, B x) { cam += cr < rm ? 1 : *csh++; if (!eqShPart(csh, esh, cr-1)) thrF("∾: Item trailing shapes must be equal (contained arrays with shapes %H and %H)", x0, c); } - if (SFNS_FILLS && !noFill(rf)) rf = fill_or(rf, getFillQ(c)); + if (SFNS_FILLS && !noFill(rf) && !fillEqualsGetFill(rf, c)) rf = bi_noFill; } if (rm==0) thrM("∾: Some item rank must be equal or greater than rank of argument"); @@ -843,7 +843,7 @@ B join_c1(B t, B x) { ur cr=0; usz* sh=NULL; if (!isAtm(c)) { cr=RNK(c); sh=SH(c); } if (cr != r1-rd) thrF("∾: Incompatible item ranks", base, c); if (!eqShPart(rd?tsh0:tsh, sh, cr)) thrF("∾: Incompatible item shapes (contained arrays with shapes %H and %H along axis %i)", base, c, a); - if (SFNS_FILLS && !noFill(rf)) rf = fill_or(rf, getFillQ(c)); + if (SFNS_FILLS && !noFill(rf) && !fillEqualsGetFill(rf, c)) rf = bi_noFill; } } tr -= a0; diff --git a/src/core/fillarr.c b/src/core/fillarr.c index 7e9fb238..393881bd 100644 --- a/src/core/fillarr.c +++ b/src/core/fillarr.c @@ -99,11 +99,9 @@ NOINLINE bool fillEqualF(B w, B x) { // doesn't consume; both args must be array u8 we = TI(w,elType); u8 xe = TI(x,elType); - if (we!=el_B && xe!=el_B) { - return elChr(we) == elChr(xe); - } - SGetU(x) - SGetU(w) + if (we!=el_B && xe!=el_B) return elNum(we) == elNum(xe); + + SGetU(x) SGetU(w) for (usz i = 0; i < ia; i++) if(!fillEqual(GetU(w,i),GetU(x,i))) return false; return true; } diff --git a/src/core/fillarr.h b/src/core/fillarr.h index d73371c4..f18d065a 100644 --- a/src/core/fillarr.h +++ b/src/core/fillarr.h @@ -101,21 +101,15 @@ static Arr* m_fillarr0p(usz ia) { // zero-initialized fillarr, with both fill & B m_unit(B x); // consumes B m_atomUnit(B x); // consumes -static B fill_or(B wf, B xf) { // consumes - if (fillEqual(wf, xf)) { - dec(wf); - return xf; - } - dec(wf); dec(xf); - return bi_noFill; -} -static bool fillEqualsGetFill(B fill, B obj) { // equal to fill_or(fill, getFillQ(obj)) +static bool fillEqualsGetFill(B fill, B obj) { // returns whether `fill` equals the fill of `obj` return fillEqual(fill, getFillN(obj)); } static B fill_both(B w, B x) { // doesn't consume - B wf = getFillQ(w); + B wf = getFillN(w); if (noFill(wf)) return bi_noFill; B xf = getFillQ(x); - return fill_or(wf, xf); + if (fillEqual(wf, xf)) return xf; + dec(xf); + return bi_noFill; }