From e4d38f571d1529f816ffd649e4dd030a1390893c Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 22 Apr 2023 13:56:38 +0300 Subject: [PATCH] move k==0 case out of for_cells_c1 --- src/builtins/cells.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/builtins/cells.c b/src/builtins/cells.c index 86923931..2a1313f2 100644 --- a/src/builtins/cells.c +++ b/src/builtins/cells.c @@ -275,10 +275,10 @@ static ur cell_rank(f64 r, f64 k) { // ⎉k over arg rank r // monadic ˘ & ⎉ -B for_cells_c1(B f, u32 xr, u32 cr, u32 k, B x, u32 chr) { // F⎉cr x, with 0≤cr≤xr, array x, and xr>0 - assert(isArr(x) && xr>0); +B for_cells_c1(B f, u32 xr, u32 cr, u32 k, B x, u32 chr) { // F⎉cr x, with array x, xr>0, 0≤cr0 && k>0 && cr0 this will always include at least one item of shape; therefore, cam≡0 → IA(x)≡0 and IA(x)≢0 → cam≢0 if (isFun(f)) { if (cam==0 || IA(x)==0) goto noSpecial; // TODO be more granular about this u8 rtid = v(f)->flags-1; @@ -406,12 +406,14 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g; SGetU(g); kf = GetU(g, gia==2).f; } if (gf) dec(g); - ur xr; - if (isAtm(x) || (xr=RNK(x))==0) { + if (isAtm(x)) { + wholeCell:; B r = c1(f, x); return isAtm(r)? m_atomUnit(r) : r; } + ur xr = RNK(x); ur cr = cell_rank(xr, kf); + if (cr==xr) goto wholeCell; return for_cells_c1(f, xr, cr, xr-cr, x, U'⎉'); }