fix x⊸≍˘list & ≍⟜x˘list on non-atom x

This commit is contained in:
dzaima 2024-09-16 00:40:09 +03:00
parent 92be360412
commit 5192a1d466
2 changed files with 17 additions and 0 deletions

View File

@ -693,6 +693,16 @@ static NOINLINE B rank2_empty(B f, B w, ur wk, B x, ur xk, u32 chr) {
return r;
}
SHOULD_INLINE bool unpack_unit(B* r) {
B x = *r;
if (isAtm(x)) return true;
if (RNK(x)!=0) return false;
B x2 = IGet(x,0);
decG(x);
*r = x2;
return true;
}
NOINLINE B for_cells_AS(B f, B w, B x, ur wcr, ur wr, u32 chr) { // F⟜x⎉wcr w; array w, wr>0, 0≤wcr<wr, k≡wr-wcr
assert(isArr(w));
ur wk = wr-wcr; assert(wk>0 && wcr<wr);
@ -704,6 +714,7 @@ NOINLINE B for_cells_AS(B f, B w, B x, ur wcr, ur wr, u32 chr) { // F⟜x⎉wcr
case n_ltack: dec(x); return w;
case n_rtack: return const_cells(w, wk, wsh, x, chr);
case n_couple: if (RNK(w)==1) {
if (!unpack_unit(&x)) break;
x = taga(arr_shVec(reshape_one(IA(w), x)));
return interleave_cells(w, x, 1);
} break;
@ -755,6 +766,7 @@ NOINLINE B for_cells_SA(B f, B w, B x, ur xcr, ur xr, u32 chr) { // w⊸F⎉xcr
}
break;
case n_couple: if (RNK(x)==1) {
if (!unpack_unit(&w)) break;
w = taga(arr_shVec(reshape_one(IA(x), w)));
return interleave_cells(w, x, 1);
} break;

View File

@ -129,6 +129,11 @@
!"≍: 𝕨 and 𝕩 must have equal shapes (⟨4⟩ ≡ ≢𝕨, ⟨5⟩ ≡ ≢𝕩)" % (342) ˘ 352
!"≍: 𝕨 and 𝕩 must have equal shapes (2‿2‿2 ≡ ≢𝕨, 2‿3‿2 ≡ ≢𝕩)" % (32222) ˘ 32322
!"≍: 𝕨 and 𝕩 must have equal shapes (4‿1 ≡ ≢𝕨, ⟨4⟩ ≡ ≢𝕩)" % (3410) ˘ 340
(<"ab") ˘ 2"cd" %% 22"ab", 'c', "ab", 'd'
(<"ab") ˘˜ 2"cd" %% 22'c', "ab", 'd', "ab"
"ab" 1 42"cd" %% 422"abcdabcdabcdabcd"
!"≍: 𝕨 and 𝕩 must have equal shapes (⟨⟩ ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)" % "ab"˘ "cd"
!"≍: 𝕨 and 𝕩 must have equal shapes (⟨2⟩ ≡ ≢𝕨, ⟨⟩ ≡ ≢𝕩)" % "ab"˘ "cd"
(
%USE IS_HEAPVERIFY