diff --git a/src/builtins/fns.c b/src/builtins/fns.c index 58fac5be..e6424200 100644 --- a/src/builtins/fns.c +++ b/src/builtins/fns.c @@ -88,8 +88,6 @@ B ud_c2(B t, B w, B x) { return c2(rt_ud, w, x); } -B pair_c1(B t, B x) { return m_v1( x); } -B pair_c2(B t, B w, B x) { return m_v2(w, x); } B ltack_c1(B t, B x) { return x; } B ltack_c2(B t, B w, B x) { dec(x); return w; } B rtack_c1(B t, B x) { return x; } diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index f78881a1..8bb4b0a3 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -39,7 +39,8 @@ B m_vec1(B a) { fillarr_ptr(ra)[0] = a; return taga(ra); } -B m_vec2(B a, B b) { + +FORCE_INLINE B m_vec2Base(B a, B b, bool fills) { if (isAtm(a)&isAtm(b)) { if (LIKELY(isNum(a)&isNum(b))) { i32 ai=a.f; i32 bi=b.f; @@ -56,9 +57,29 @@ B m_vec2(B a, B b) { else { u32* rp; B r = m_c32arrv(&rp, 2); rp[0]=ac; rp[1]=bc; return r; } } } + if (fills) { + if (isAtm(a) || isAtm(b)) goto noFills; + B af = asFill(inc(a)); + if (noFill(af)) goto noFills; + B bf = asFill(inc(b)); + if (noFill(bf)) { dec(af); goto noFills; } + if (!fillEqual(af,bf)) { dec(bf); dec(af); goto noFills; } + dec(bf); + Arr* ra = m_fillarrp(2); arr_shVec(ra); + fillarr_setFill(ra, af); + fillarr_ptr(ra)[0] = a; + fillarr_ptr(ra)[1] = b; + return taga(ra); + } + noFills: return m_v2(a,b); } +B m_vec2(B a, B b) { return m_vec2Base(a, b, false); } + +B pair_c1(B t, B x) { return m_v1(x); } +B pair_c2(B t, B w, B x) { return m_vec2Base(w, x, true); } + B shape_c1(B t, B x) { if (isAtm(x)) return m_vec1(x); usz ia = a(x)->ia; diff --git a/src/core/stuff.h b/src/core/stuff.h index 3f6f3ad5..988ecf8c 100644 --- a/src/core/stuff.h +++ b/src/core/stuff.h @@ -96,8 +96,8 @@ static B m_v1(B a ); // consumes all static B m_v2(B a, B b ); // consumes all static B m_v3(B a, B b, B c ); // consumes all static B m_v4(B a, B b, B c, B d); // consumes all -B m_vec1(B a); -B m_vec2(B a, B b); +B m_vec1(B a); // complete fills +B m_vec2(B a, B b); // incomplete fills // random stuff diff --git a/src/load.c b/src/load.c index 08ae877c..bba4c63d 100644 --- a/src/load.c +++ b/src/load.c @@ -236,7 +236,7 @@ void load_init() { // very last init function bool rtComplete[] = { /* +-×÷⋆√⌊⌈|¬ */ 1,1,1,1,1,1,1,1,1,1, /* ∧∨<>≠=≤≥≡≢ */ 1,1,1,1,1,1,1,1,1,1, - /* ⊣⊢⥊∾≍⋈↑↓↕« */ 1,1,1,1,1,0,1,1,1,1, + /* ⊣⊢⥊∾≍⋈↑↓↕« */ 1,1,1,1,1,1,1,1,1,1, /* »⌽⍉/⍋⍒⊏⊑⊐⊒ */ 1,1,0,1,1,1,1,1,1,1, /* ∊⍷⊔!˙˜˘¨⌜⁼ */ 1,1,1,1,1,1,1,1,1,0, /* ´˝`∘○⊸⟜⌾⊘◶ */ 1,0,1,1,1,1,1,1,1,1,