any_squeeze → squeeze_any
This commit is contained in:
parent
f1cb141f56
commit
b9ccafcf3f
@ -116,7 +116,7 @@ B sum_c1(B t, B x) {
|
|||||||
if (ia==0) { decG(x); return m_f64(0); }
|
if (ia==0) { decG(x); return m_f64(0); }
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
if (!elNum(xe)) {
|
if (!elNum(xe)) {
|
||||||
x = any_squeeze(x); xe = TI(x,elType);
|
x = squeeze_any(x); xe = TI(x,elType);
|
||||||
if (!elNum(xe)) thrF("•math.Sum 𝕩: 𝕩 elements must be numbers", x);
|
if (!elNum(xe)) thrF("•math.Sum 𝕩: 𝕩 elements must be numbers", x);
|
||||||
}
|
}
|
||||||
f64 r;
|
f64 r;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ B refc_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
B squeeze_c1(B t, B x) {
|
B squeeze_c1(B t, B x) {
|
||||||
if (!isArr(x)) return x;
|
if (!isArr(x)) return x;
|
||||||
return any_squeeze(x);
|
return squeeze_any(x);
|
||||||
}
|
}
|
||||||
B deepSqueeze_c1(B t, B x) {
|
B deepSqueeze_c1(B t, B x) {
|
||||||
return squeeze_deep(x);
|
return squeeze_deep(x);
|
||||||
@ -429,7 +429,7 @@ bool validate_flags(bool crash, B x) {
|
|||||||
if (isArr(x) && IA(x)!=0) {
|
if (isArr(x) && IA(x)!=0) {
|
||||||
if (FL_HAS(x, fl_squoze)) {
|
if (FL_HAS(x, fl_squoze)) {
|
||||||
B t = unshare(x);
|
B t = unshare(x);
|
||||||
t = any_squeeze(t);
|
t = squeeze_any(t);
|
||||||
if (TI(t,elType) != TI(x,elType)) validate_fail(crash, "Validate: Wrongly squeezed: array has eltype %S, expected %S", eltype_repr(TI(x,elType)), eltype_repr(TI(t,elType)));
|
if (TI(t,elType) != TI(x,elType)) validate_fail(crash, "Validate: Wrongly squeezed: array has eltype %S, expected %S", eltype_repr(TI(x,elType)), eltype_repr(TI(t,elType)));
|
||||||
decG(t);
|
decG(t);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ B each_c1(Md1D* d, B x) { B f = d->f;
|
|||||||
u8 rtid = RTID(f);
|
u8 rtid = RTID(f);
|
||||||
if (rtid==n_ltack || rtid==n_rtack) {
|
if (rtid==n_ltack || rtid==n_rtack) {
|
||||||
if (EACH_FILLS) dec(xf);
|
if (EACH_FILLS) dec(xf);
|
||||||
return TI(x,arrD1) || IA(x)==0? x : any_squeeze(EACH_FILLS? x : withFill(x, bi_noFill));
|
return TI(x,arrD1) || IA(x)==0? x : squeeze_any(EACH_FILLS? x : withFill(x, bi_noFill));
|
||||||
}
|
}
|
||||||
r = eachm_fn(f, x, c(Fun,f)->c1);
|
r = eachm_fn(f, x, c(Fun,f)->c1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -93,7 +93,7 @@ NOINLINE B repeat_replaceR(B g, B* q) {
|
|||||||
usz ia = IA(g);
|
usz ia = IA(g);
|
||||||
M_HARR(r, ia);
|
M_HARR(r, ia);
|
||||||
for (usz i = 0; i < ia; i++) HARR_ADD(r, i, repeat_replace(GetU(g,i), q));
|
for (usz i = 0; i < ia; i++) HARR_ADD(r, i, repeat_replace(GetU(g,i), q));
|
||||||
return any_squeeze(HARR_FC(r, g));
|
return squeeze_any(HARR_FC(r, g));
|
||||||
}
|
}
|
||||||
#define REPEAT_T(CN, END, ...) \
|
#define REPEAT_T(CN, END, ...) \
|
||||||
B g = CN(d->g, __VA_ARGS__ inc(x)); \
|
B g = CN(d->g, __VA_ARGS__ inc(x)); \
|
||||||
|
|||||||
@ -273,7 +273,7 @@ B shape_c2(B t, B w, B x) {
|
|||||||
x = TO_GET(x, 0);
|
x = TO_GET(x, 0);
|
||||||
goto unit;
|
goto unit;
|
||||||
}
|
}
|
||||||
if (xia <= nia/2) x = any_squeeze(x);
|
if (xia <= nia/2) x = squeeze_any(x);
|
||||||
|
|
||||||
u8 xl = arrTypeBitsLog(TY(x));
|
u8 xl = arrTypeBitsLog(TY(x));
|
||||||
u8 xt = arrNewType(TY(x));
|
u8 xt = arrNewType(TY(x));
|
||||||
@ -414,7 +414,7 @@ static B recPick(B w, B x) { // doesn't consume
|
|||||||
if (isAtm(c)) thrM("𝕨⊑𝕩: 𝕨 contained list with mixed-type elements");
|
if (isAtm(c)) thrM("𝕨⊑𝕩: 𝕨 contained list with mixed-type elements");
|
||||||
HARR_ADD(r, i, recPick(c, x));
|
HARR_ADD(r, i, recPick(c, x));
|
||||||
}
|
}
|
||||||
return any_squeeze(HARR_FC(r, w));
|
return squeeze_any(HARR_FC(r, w));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -651,7 +651,7 @@ B slash_c2(B t, B w, B x) {
|
|||||||
u64 s;
|
u64 s;
|
||||||
u8 we = TI(w,elType);
|
u8 we = TI(w,elType);
|
||||||
if (!elInt(we)) {
|
if (!elInt(we)) {
|
||||||
w=any_squeeze(w); we=TI(w,elType); // TODO move squeeze to before depth(w)
|
w=squeeze_any(w); we=TI(w,elType); // TODO move squeeze to before depth(w)
|
||||||
if (!elInt(we)) {
|
if (!elInt(we)) {
|
||||||
s = usum(w);
|
s = usum(w);
|
||||||
goto arrW_base;
|
goto arrW_base;
|
||||||
|
|||||||
@ -256,7 +256,7 @@ NOINLINE B int_squeeze_sorted(B x, Arr* xa, u8 type, ux ia) {
|
|||||||
u8 xe = TI(x,elType); \
|
u8 xe = TI(x,elType); \
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
|
|
||||||
NOINLINE B any_squeeze(B x) {
|
NOINLINE B squeeze_any(B x) {
|
||||||
SQ_READ;
|
SQ_READ;
|
||||||
SQ_FAST_EXT(, return x);
|
SQ_FAST_EXT(, return x);
|
||||||
if (ia==0) return FL_SET(x, fl_squoze); // TODO return a version of the smallest type?
|
if (ia==0) return FL_SET(x, fl_squoze); // TODO return a version of the smallest type?
|
||||||
@ -296,7 +296,7 @@ B squeeze_chrOut(B x) { return squeeze_chrTryImpl(x).r; }
|
|||||||
|
|
||||||
B squeeze_deep(B x) {
|
B squeeze_deep(B x) {
|
||||||
if (!isArr(x)) return x;
|
if (!isArr(x)) return x;
|
||||||
x = any_squeeze(x);
|
x = squeeze_any(x);
|
||||||
if (TI(x,elType)!=el_B) return x;
|
if (TI(x,elType)!=el_B) return x;
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
M_HARR(r, ia)
|
M_HARR(r, ia)
|
||||||
@ -308,5 +308,5 @@ B squeeze_deep(B x) {
|
|||||||
SGet(x);
|
SGet(x);
|
||||||
for (ux i=0; i<ia; i++) { HARR_ADD(r, i, squeeze_deep(Get(x,i))); }
|
for (ux i=0; i<ia; i++) { HARR_ADD(r, i, squeeze_deep(Get(x,i))); }
|
||||||
}
|
}
|
||||||
return any_squeeze(qWithFill(HARR_FCD(r, x), xf));
|
return squeeze_any(qWithFill(HARR_FCD(r, x), xf));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -279,7 +279,7 @@ B bqn_merge(B x, u32 type); // consumes
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
B any_squeeze(B x); // consumes; accepts any array, returns one with the smallest type (doesn't recurse!)
|
B squeeze_any(B x); // consumes; accepts any array, returns one with the smallest type (doesn't recurse!)
|
||||||
B squeeze_deep(B x); // consumes; accepts any object, returns an object with all parts necessary for equality checking & hashing squeezed; if this function errors due to OOM, the argument won't yet be consumed
|
B squeeze_deep(B x); // consumes; accepts any object, returns an object with all parts necessary for equality checking & hashing squeezed; if this function errors due to OOM, the argument won't yet be consumed
|
||||||
|
|
||||||
typedef struct { B r; u8 re; } SqRes;
|
typedef struct { B r; u8 re; } SqRes;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ B eachd_fn(B fo, B w, B x, FC2 f) {
|
|||||||
} else {
|
} else {
|
||||||
dec(rw? x : w);
|
dec(rw? x : w);
|
||||||
}
|
}
|
||||||
return any_squeeze(r.b);
|
return squeeze_any(r.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
B bo = wg? w : x;
|
B bo = wg? w : x;
|
||||||
@ -55,7 +55,7 @@ B eachd_fn(B fo, B w, B x, FC2 f) {
|
|||||||
if (wg) for (usz i = 0; i < min; i++) { B c=incBy(Get(x,i), ext-1); for (usz j=0; j<ext; j++) HARR_ADDA(r, f(fo, Get(w,HARR_I(r)), c)); }
|
if (wg) for (usz i = 0; i < min; i++) { B c=incBy(Get(x,i), ext-1); for (usz j=0; j<ext; j++) HARR_ADDA(r, f(fo, Get(w,HARR_I(r)), c)); }
|
||||||
else for (usz i = 0; i < min; i++) { B c=incBy(Get(w,i), ext-1); for (usz j=0; j<ext; j++) HARR_ADDA(r, f(fo, c, Get(x,HARR_I(r)))); }
|
else for (usz i = 0; i < min; i++) { B c=incBy(Get(w,i), ext-1); for (usz j=0; j<ext; j++) HARR_ADDA(r, f(fo, c, Get(x,HARR_I(r)))); }
|
||||||
}
|
}
|
||||||
rb = any_squeeze(HARR_FC(r, bo));
|
rb = squeeze_any(HARR_FC(r, bo));
|
||||||
}
|
}
|
||||||
dec(w); dec(x);
|
dec(w); dec(x);
|
||||||
return rb;
|
return rb;
|
||||||
@ -100,7 +100,7 @@ B eachm_fn(B fo, B x, FC1 f) {
|
|||||||
}
|
}
|
||||||
REUSE(x);
|
REUSE(x);
|
||||||
for (; i < ia; i++) xp[i] = f(fo, mv(xp, i));
|
for (; i < ia; i++) xp[i] = f(fo, mv(xp, i));
|
||||||
return any_squeeze(x);
|
return squeeze_any(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
base:;
|
base:;
|
||||||
@ -118,7 +118,7 @@ B eachm_fn(B fo, B x, FC1 f) {
|
|||||||
case el_c16: for (; i<ia; i++) HARR_ADD(r, i, f(fo, m_c32(((u16*)xp)[i]))); break;
|
case el_c16: for (; i<ia; i++) HARR_ADD(r, i, f(fo, m_c32(((u16*)xp)[i]))); break;
|
||||||
case el_c32: for (; i<ia; i++) HARR_ADD(r, i, f(fo, m_c32(((u32*)xp)[i]))); break;
|
case el_c32: for (; i<ia; i++) HARR_ADD(r, i, f(fo, m_c32(((u32*)xp)[i]))); break;
|
||||||
}
|
}
|
||||||
return any_squeeze(HARR_FCD(r, x));
|
return squeeze_any(HARR_FCD(r, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SEMANTIC_CATCH
|
#if SEMANTIC_CATCH
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
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))
|
static inline B squeezed_unit(B x) { // same fill as squeeze_any(m_hunit(x))
|
||||||
return isAtm(x)? m_unit(x) : m_hunit(x);
|
return isAtm(x)? m_unit(x) : m_hunit(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ NOINLINE u64 bqn_hashObj(B x, const u64 secret[4]) { // TODO manual separation o
|
|||||||
if (isArr(x)) {
|
if (isArr(x)) {
|
||||||
usz xia = IA(x);
|
usz xia = IA(x);
|
||||||
if (xia==0) return ~secret[3]; // otherwise squeeze will care about fills
|
if (xia==0) return ~secret[3]; // otherwise squeeze will care about fills
|
||||||
x = any_squeeze(incG(x));
|
x = squeeze_any(incG(x));
|
||||||
u8 xr = RNK(x);
|
u8 xr = RNK(x);
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
u64 shHash;
|
u64 shHash;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user