From 06689960a5ad298a607625ef00a18bec3c9338af Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 23 Aug 2024 02:44:49 +0300 Subject: [PATCH] =?UTF-8?q?native=20=E2=89=8D=E2=81=BC=E2=8D=9Fk=20?= =?UTF-8?q?=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/cells.c | 13 +++++++++++++ test/cases/cells.bqn | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/builtins/cells.c b/src/builtins/cells.c index 42667ba0..b01c71f9 100644 --- a/src/builtins/cells.c +++ b/src/builtins/cells.c @@ -5,6 +5,7 @@ #include B fne_c1(B, B); +B shape_c1(B, B); B shape_c2(B, B, B); B transp_c2(B, B, B); B take_c2(B, B, B); @@ -583,6 +584,18 @@ B for_cells_c1(B f, u32 xr, u32 cr, u32 k, B x, u32 chr) { // F⎉cr x; array x, } break; } + case n_undo: if (isFun(fd->f)) { + u8 frtid = v(fd->f)->flags-1; + if (frtid==n_couple && cr!=0 && xsh[k]==1) { + assert(xr>=2); + if (xr==2) return C1(shape, x); + Arr* r = cpyWithShape(x); xsh=PSH(r); + ShArr* rsh = m_shArr(xr-1); + shcpy(rsh->a, xsh, k); + shcpy(rsh->a+k, xsh+k+1, xr-k-1); + return taga(arr_shReplace(r, xr-1, rsh)); + } + } break; } } else if (TY(f) == t_md2D) { Md2D* fd = c(Md2D,f); diff --git a/test/cases/cells.bqn b/test/cases/cells.bqn index 597aec30..d4dccb2a 100644 --- a/test/cases/cells.bqn +++ b/test/cases/cells.bqn @@ -103,6 +103,19 @@ [2‿1,4‿5]⊸⊏˘ 10‿8⥊↕100 %% (8×↕10) +⌜ [2‿1,4‿5] [1‿1,0‿1]⊸⊏˘ 10‿2‿2⥊↕100 %% (4×↕10) +⌜ 2‿2‿2⥊2‿3‿2‿3‿0‿1‿2‿3 +≍⁼˘ 10‿1⥊↕10 %% ↕10 +≍⁼˘ 10‿1‿3⥊↕30 %% 10‿3⥊↕30 +≍⁼˘ 10‿1‿3‿2⥊↕60 %% 10‿3‿2⥊↕60 +≍⁼⎉¯2 4‿2‿1⥊↕8 %% 4‿2⥊↕8 +≍⁼⎉¯2 4‿2‿1‿3⥊↕24 %% 4‿2‿3⥊↕24 +≍⁼⎉¯2 4‿2‿1‿3‿2⥊↕48 %% 4‿2‿3‿2⥊↕48 +≍⁼⎉1 ⋈"foo" %% <"foo" +≍⁼⎉1 ⋈10 %% <10 +!"≍⁼: Argument must have a leading axis of 1" % ≍⁼˘ 1‿10⥊2 +!"≍⁼: Argument must have a leading axis of 1" % ≍⁼⎉¯2 1‿1‿2‿1‿1⥊1 +!"≍⁼: Argument must have a leading axis of 1" % ≍⁼⎉¯2 1‿1⥊10 +!"≍⁼: Argument must have a leading axis of 1" % ≍⁼⎉0 ⋈10 + ( %USE IS_HEAPVERIFY # big ˝˘ & `˘ tester