add best effort guesses for builtins/cmp,fns,fold.c

I'm not sure about modifiers so I left them without arguments
This commit is contained in:
tankorsmash 2025-02-05 19:32:49 -05:00
parent 559b3f0d6e
commit dd5d17ca83
3 changed files with 20 additions and 20 deletions

View File

@ -154,7 +154,7 @@ B leading_axis_arith(FC2 fc2, B w, B x, usz* wsh, usz* xsh, ur mr);
if (ria) cmp_fns_##NAME##AA[we](rp, tyany_ptr(w), tyany_ptr(x), ria); \
decG(w);decG(x); return r; \
base: return NAME##_rec(swapped,w,x); \
badShape: thrF("%U: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", swapped?CR:CN, swapped?x:w, swapped?w:x); \
badShape: thrF("𝕨%U𝕩: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", swapped?CR:CN, swapped?x:w, swapped?w:x); \
}
CMP_AA_D("", "", ge, )
CMP_AA_D(">", "<", gt, )

View File

@ -60,8 +60,8 @@ static B* ud_rec(B* p, usz d, usz r, i32* pos, usz* sh) {
NOINLINE B list_range(B x) {
SGetU(x)
usz xia = IA(x);
if (RNK(x)!=1) thrF(": Argument must be either an integer or integer list (had rank %i)", RNK(x));
if (xia>UR_MAX) thrF(": Result rank too large (%s≡≠𝕩)", xia);
if (RNK(x)!=1) thrF("𝕩: 𝕩 must be either an integer or integer list (had rank %i)", RNK(x));
if (xia>UR_MAX) thrF("𝕩: Result rank too large (%s≡≠𝕩)", xia);
if (xia==0) { decG(x); return m_funit(emptyIVec()); }
usz sh[xia]; // stack allocation of rank items
i32 pos[xia];
@ -73,7 +73,7 @@ NOINLINE B list_range(B x) {
good|= c==0;
bad|= (c > I32_MAX) | mulOn(ria, c);
}
if (bad && !good) thrM(": Result too large");
if (bad && !good) thrM("𝕩: Result too large");
decG(x);
Arr* r = m_fillarr0p(ria);
@ -110,13 +110,13 @@ B slash_c2(B t, B w, B x);
B ud_c2(B t, B w, B x) {
usz wia=1;
if (isArr(w)) {
if (RNK(w)>1) thrM("↕: 𝕨 must have rank at most 1");
if (RNK(w)>1) thrM("𝕨𝕩: 𝕨 must have rank at most 1");
wia = IA(w);
if (wia==0) { decG(w); return isArr(x)? x : m_unit(x); }
}
ur xr;
if (isAtm(x) || (xr=RNK(x))<wia) thrM("↕: Length of 𝕨 must be at most rank of 𝕩");
if (xr+wia > UR_MAX) thrM("↕: Result rank too large");
if (isAtm(x) || (xr=RNK(x))<wia) thrM("𝕨𝕩: Length of 𝕨 must be at most rank of 𝕩");
if (xr+wia > UR_MAX) thrM("𝕨𝕩: Result rank too large");
ur wr = wia;
ur rr = xr + wr;
ShArr* sh = m_shArr(rr);
@ -135,7 +135,7 @@ B ud_c2(B t, B w, B x) {
for (usz i=0; i<wr; i++) {
usz l = xsh[i] + 1;
usz m = wsh[i];
if (l<m) thrM("↕: Window length 𝕨 must be at most axis length plus one");
if (l<m) thrM("𝕨𝕩: Window length 𝕨 must be at most axis length plus one");
empty|= m==0 | m==l;
rsh[i] = l - m;
}
@ -153,9 +153,9 @@ B ud_c2(B t, B w, B x) {
ur fr=2*wr; // Frame rank in result
usz cia=1; // Cell length
for (usz i=fr; i<rr; i++) if (mulOn(cia, rsh[i])) thrM("↕: result shape too large");
for (usz i=fr; i<rr; i++) if (mulOn(cia, rsh[i])) thrM("𝕨𝕩: result shape too large");
usz ria=cia;
for (usz i=0; i<fr; i++) if (mulOn(ria, rsh[i])) thrM("↕: result shape too large");
for (usz i=0; i<fr; i++) if (mulOn(ria, rsh[i])) thrM("𝕨𝕩: result shape too large");
TALLOC(usz, ri, fr-1);
MAKE_MUT_INIT(r, ria, TI(x,elType));
MUTG_INIT(r);
@ -233,7 +233,7 @@ extern GLOBAL B rt_find;
B find_c2(B t, B w, B x) {
ur wr = isAtm(w) ? 0 : RNK(w);
ur xr = isAtm(x) ? 0 : RNK(x);
if (wr > xr) thrF("⍷: Rank of 𝕨 must be at most rank of 𝕩 (%i≡=𝕨, %i≡=𝕩)", wr, xr);
if (wr > xr) thrF("𝕨𝕩: Rank of 𝕨 must be at most rank of 𝕩 (%i≡=𝕨, %i≡=𝕩)", wr, xr);
u8 xe, we ONLY_GCC(= 0);
B r;
if (xr==1 && (xe=TI(x,elType))!=el_B && xe!=el_bit && (isAtm(w) || (we=TI(w,elType))!=el_B)) {

View File

@ -103,13 +103,13 @@ static i64 (*const sum_small_fns[])(void*, usz) = { sum_small_i8, sum_small_i16,
static f64 (*const sum_fns[])(void*, usz, f64) = { sum_i8, sum_i16, sum_i32, sum_f64 };
B sum_c1(B t, B x) {
if (isAtm(x) || RNK(x)!=1) thrF("•math.Sum: Argument must be a list (%H ≡ ≢𝕩)", x);
if (isAtm(x) || RNK(x)!=1) thrF("•math.Sum𝕩: Argument must be a list (%H ≡ ≢𝕩)", x);
usz ia = IA(x);
if (ia==0) { decG(x); return m_f64(0); }
u8 xe = TI(x,elType);
if (!elNum(xe)) {
x = any_squeeze(x); xe = TI(x,elType);
if (!elNum(xe)) thrF("•math.Sum: Argument elements must be numbers", x);
if (!elNum(xe)) thrF("•math.Sum𝕩: Argument elements must be numbers", x);
}
f64 r;
void* xv = tyany_ptr(x);
@ -180,7 +180,7 @@ static f64 (*const min_fns[])(void*, usz) = { min_i8, min_i16, min_i32, min_f64
static f64 (*const max_fns[])(void*, usz) = { max_i8, max_i16, max_i32, max_f64 };
B fold_c1(Md1D* d, B x) { B f = d->f;
if (isAtm(x) || RNK(x)!=1) thrF("´: Argument must be a list (%H ≡ ≢𝕩)", x);
if (isAtm(x) || RNK(x)!=1) thrF("´𝕩: Argument must be a list (%H ≡ ≢𝕩)", x);
usz ia = IA(x);
if (ia<=2) {
if (ia==2) {
@ -197,7 +197,7 @@ B fold_c1(Md1D* d, B x) { B f = d->f;
B r = TI(f,identity)(f);
if (!q_N(r)) return r;
}
thrM("´: Identity not found");
thrM("´𝕩: Identity not found");
}
}
if (RARE(!isFun(f))) { decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
@ -268,7 +268,7 @@ B fold_c1(Md1D* d, B x) { B f = d->f;
}
B fold_c2(Md1D* d, B w, B x) { B f = d->f;
if (isAtm(x) || RNK(x)!=1) thrF("´: 𝕩 must be a list (%H ≡ ≢𝕩)", x);
if (isAtm(x) || RNK(x)!=1) thrF("𝕨´𝕩: 𝕩 must be a list (%H ≡ ≢𝕩)", x);
usz ia = IA(x);
if (RARE(ia==0)) { decG(x); return w; }
if (RARE(!isFun(f))) { dec(w); decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
@ -385,7 +385,7 @@ extern B insert_base(B f, B x, bool has_w, B w); // from cells.c
B insert_c1(Md1D* d, B x) { B f = d->f;
ur xr;
if (isAtm(x) || (xr=RNK(x))==0) thrM("˝: 𝕩 must have rank at least 1");
if (isAtm(x) || (xr=RNK(x))==0) thrM("˝𝕩: 𝕩 must have rank at least 1");
usz len = *SH(x);
if (len==0) {
if (isFun(f)) {
@ -400,11 +400,11 @@ B insert_c1(Md1D* d, B x) { B f = d->f;
}
decG(x); return taga(r);
} else if (RTID(f) == n_join) {
if (xr <= 1) thrM("˝: Identity does not exist");
if (xr <= 1) thrM("˝𝕩: Identity does not exist");
goto join;
}
}
thrM("˝: Identity not found");
thrM("˝𝕩: Identity not found");
}
if (len==1) return C1(select, x);
if (RARE(!isFun(f))) { decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
@ -444,7 +444,7 @@ B insert_c1(Md1D* d, B x) { B f = d->f;
}
B insert_c2(Md1D* d, B w, B x) { B f = d->f;
ur xr;
if (isAtm(x) || (xr=RNK(x))==0) thrM("˝: 𝕩 must have rank at least 1");
if (isAtm(x) || (xr=RNK(x))==0) thrM("𝕨˝𝕩: 𝕩 must have rank at least 1");
usz len = *SH(x);
if (len==0) { decG(x); return w; }
if (RARE(!isFun(f))) { dec(w); decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }