From 0572fcc5b2f113b044bf932a2ac8c109e13185b9 Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 18 May 2023 01:30:16 +0300 Subject: [PATCH] =?UTF-8?q?native=20F=E2=8C=BE(list=E2=8A=B8=E2=8A=91)=20&?= =?UTF-8?q?=20=E2=8C=BE(listOfLists=E2=8A=B8=E2=8A=91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 31 +++++++------- src/builtins/sfns.c | 99 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 97 insertions(+), 33 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index 02707911..433d7424 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -362,17 +362,7 @@ B select_c2(B t, B w, B x) { - - -B select_ucw(B t, B o, B w, B x) { - if (isAtm(x) || RNK(x)!=1 || isAtm(w)) return def_fn_ucw(t, o, w, x); - usz xia = IA(x); - usz wia = IA(w); - SGetU(w) - if (TI(w,elType)!=el_i32) for (usz i = 0; i < wia; i++) if (!q_i64(GetU(w,i))) return def_fn_ucw(t, o, w, x); - B arg = select_c2(t, incG(w), incG(x)); - B rep = c1(o, arg); - if (isAtm(rep) || !eqShape(w, rep)) thrF("π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected %H, got %H)", w, rep); +B select_replace(u32 chr, B w, B x, B rep, usz wia, usz xia) { // rep⌾(w⊏β₯Š) x #if CHECK_VALID TALLOC(bool, set, xia); bool sparse = wia < xia/64; @@ -381,9 +371,9 @@ B select_ucw(B t, B o, B w, B x) { if (sparse) for (usz i = 0; i < wia; i++) { \ i64 cw = WI; if (RARE(cw<0)) cw+= (i64)xia; set[cw] = false; \ } - #define EQ(F) if (set[cw] && (F)) thrM("π”½βŒΎ(a⊸⊏): Incompatible result elements"); set[cw] = true; + #define EQ(F) if (set[cw] && (F)) thrF("π”½βŒΎ(a⊸%c): Incompatible result elements", chr); set[cw] = true; #define FREE_CHECK TFREE(set) - SLOWIF(xia>100 && wia100 && wia100 && wia100 && wia