more uniform F¨ fill behavior
This commit is contained in:
parent
b14ea82218
commit
3ae7d134d2
@ -40,7 +40,7 @@ B each_c1(Md1D* d, B x) { B f = d->f;
|
|||||||
B r, xf;
|
B r, xf;
|
||||||
if (EACH_FILLS) xf = getFillR(x);
|
if (EACH_FILLS) xf = getFillR(x);
|
||||||
|
|
||||||
if (isAtm(x)) r = m_hunit(c1(f, x));
|
if (isAtm(x)) r = squeezed_unit(c1(f, x));
|
||||||
else if (isFun(f)) {
|
else if (isFun(f)) {
|
||||||
u8 rtid = RTID(f);
|
u8 rtid = RTID(f);
|
||||||
if (rtid==n_ltack || rtid==n_rtack) {
|
if (rtid==n_ltack || rtid==n_rtack) {
|
||||||
@ -134,7 +134,7 @@ B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
|||||||
}
|
}
|
||||||
|
|
||||||
static B eachd(B f, B w, B x) {
|
static B eachd(B f, B w, B x) {
|
||||||
if (isAtm(w) & isAtm(x)) return m_hunit(c2(f, w, x));
|
if (isAtm(w) & isAtm(x)) return squeezed_unit(c2(f, w, x));
|
||||||
return eachd_fn(f, w, x, c2fn(f));
|
return eachd_fn(f, w, x, c2fn(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ B eachd_fn(B fo, B w, B x, FC2 f) {
|
|||||||
bool wg = wr>xr;
|
bool wg = wr>xr;
|
||||||
ur rM = wg? wr : xr;
|
ur rM = wg? wr : xr;
|
||||||
ur rm = wg? xr : wr;
|
ur rm = wg? xr : wr;
|
||||||
if (rM==0) return m_funit(f(fo, w, x));
|
if (rM==0) return squeezed_unit(f(fo, w, x));
|
||||||
if (rm && !eqShPart(SH(w), SH(x), rm)) thrF("Mapping: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
|
if (rm && !eqShPart(SH(w), SH(x), rm)) thrF("Mapping: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
|
||||||
bool rw = rM==wr && reusable(w) && TY(w)==t_harr; // dereferencing is safe as rank>0 from rM==
|
bool rw = rM==wr && reusable(w) && TY(w)==t_harr; // dereferencing is safe as rank>0 from rM==
|
||||||
bool rx = rM==xr && reusable(x) && TY(x)==t_harr;
|
bool rx = rM==xr && reusable(x) && TY(x)==t_harr;
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
B eachd_fn(B fo, B w, B x, FC2 f); // consumes w,x; assumes at least one is array
|
B eachd_fn(B fo, B w, B x, FC2 f); // consumes w,x; assumes at least one is array
|
||||||
B eachm_fn(B fo, B x, FC1 f); // consumes x; x must be array
|
B eachm_fn(B fo, B x, FC1 f); // consumes x; x must be array
|
||||||
|
|
||||||
|
static inline B squeezed_unit(B x) { // same fill as any_squeeze(m_hunit(x))
|
||||||
|
return isAtm(x)? m_unit(x) : m_hunit(x);
|
||||||
|
}
|
||||||
|
|
||||||
#if SEMANTIC_CATCH
|
#if SEMANTIC_CATCH
|
||||||
NOINLINE B arith_recd(FC2 f, B w, B x);
|
NOINLINE B arith_recd(FC2 f, B w, B x);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
%DEF fill Fill←•internal.HasFill◶'e'‿{⊑1↑0⥊𝕩}
|
%DEF fill Fill←•internal.HasFill◶'e'‿{⊑1↑0⥊𝕩}
|
||||||
|
%DEF eqall EqAll ← {!∘≡⟜(⊑𝕩)¨ 𝕩 ⋄ ⊑𝕩}
|
||||||
|
|
||||||
%USE fill ⋄ F←⌊ ⋄ ⟨0,1,{⇐},+,@,'𝕩'⟩ Fill∘F⌜ ⟨⟨⟩, ↕0‿0, ↕0, 0‿2⥊↕0, "", 2‿0⥊""⟩ %!HEAPVERIFY %% 2‿4/[⟨'e',0‿0,0,0,'e','e'⟩,⟨'e','e','e','e','e','e'⟩]
|
%USE fill ⋄ F←⌊ ⋄ ⟨0,1,{⇐},+,@,'𝕩'⟩ Fill∘F⌜ ⟨⟨⟩, ↕0‿0, ↕0, 0‿2⥊↕0, "", 2‿0⥊""⟩ %!HEAPVERIFY %% 2‿4/[⟨'e',0‿0,0,0,'e','e'⟩,⟨'e','e','e','e','e','e'⟩]
|
||||||
%USE fill ⋄ F←+ ⋄ ⟨0,1,{⇐},+,@,'𝕩'⟩ Fill∘F⌜ ⟨⟨⟩, ↕0‿0, ↕0, 0‿2⥊↕0, "", 2‿0⥊""⟩ %!HEAPVERIFY %% 6‿6⥊⟨'e',0‿0,0,0,' ',' ','e',0‿0,0,0,' ',' ','e','e','e','e','e','e','e','e','e','e','e','e','e'," ",' ',' ','e','e','e'," ",' ',' ','e','e'⟩
|
%USE fill ⋄ F←+ ⋄ ⟨0,1,{⇐},+,@,'𝕩'⟩ Fill∘F⌜ ⟨⟨⟩, ↕0‿0, ↕0, 0‿2⥊↕0, "", 2‿0⥊""⟩ %!HEAPVERIFY %% 6‿6⥊⟨'e',0‿0,0,0,' ',' ','e',0‿0,0,0,' ',' ','e','e','e','e','e','e','e','e','e','e','e','e','e'," ",' ',' ','e','e','e'," ",' ',' ','e','e'⟩
|
||||||
@ -34,6 +35,13 @@
|
|||||||
{3↑ (2⥊2)-˝𝕩‿2⥊<<'x'}¨ 5‿6 %!HEAPVERIFY %% <¨¨ ⟨"vv ", 2‿2‿0⟩
|
{3↑ (2⥊2)-˝𝕩‿2⥊<<'x'}¨ 5‿6 %!HEAPVERIFY %% <¨¨ ⟨"vv ", 2‿2‿0⟩
|
||||||
{3↑ "ee"-˝𝕩‿2⥊<<'a'}¨ 5‿6 %!HEAPVERIFY %% <¨¨ ⟨¯4‿¯4‿0, "ee "⟩
|
{3↑ "ee"-˝𝕩‿2⥊<<'a'}¨ 5‿6 %!HEAPVERIFY %% <¨¨ ⟨¯4‿¯4‿0, "ee "⟩
|
||||||
|
|
||||||
|
%DEF sqfill SqFill ← {•internal.Squeeze "Ah"•internal.Variation 𝕩}
|
||||||
|
%USE fill ⋄ %USE eqall ⋄ %USE sqfill ⋄ F←•internal.Keep∘⊢ ⋄ {EqAll Fill¨ ⟨SqFill ⟨𝕩⟩, F¨<𝕩, @F¨<𝕩, @F¨⋈𝕩⟩}¨ ⟨"abc", 4, 'a', {⇐}⟩
|
||||||
|
%USE fill ⋄ %USE eqall ⋄ %USE sqfill ⋄ F←•internal.Keep∘⊢ ⋄ {EqAll Fill¨ ⟨SqFill ⥊𝕩, F¨ 𝕩, @F¨ 𝕩 ⟩}¨ ⟨"abc", 4, 'a', {⇐}⟩
|
||||||
|
|
||||||
|
2↑ 'a'⊸+¨ 1 %% "b "
|
||||||
|
2↑ {⇐} 'a'⊸+¨ 1 %% "b "
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# ⟨↑‿3⥊↕10 ⋄ ↑‿3⥊<¨↕10 ⋄ ↑‿3⥊<˘↕10⟩
|
# ⟨↑‿3⥊↕10 ⋄ ↑‿3⥊<¨↕10 ⋄ ↑‿3⥊<˘↕10⟩
|
||||||
# 5‿¯5↑⌜⟨↕2 ⋄ "ab" ⋄ <¨↕2 ⋄ <˘↕2⟩
|
# 5‿¯5↑⌜⟨↕2 ⋄ "ab" ⋄ <¨↕2 ⋄ <˘↕2⟩
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user