From 8188886538d20183a321d2897776ff4c55f21d4b Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 18 Dec 2022 23:49:09 +0200 Subject: [PATCH] =?UTF-8?q?fast=20=F0=9D=94=BD=C2=B4=E2=9F=A8x=E2=9F=A9=20?= =?UTF-8?q?&=20=F0=9D=94=BD=C2=B4=E2=9F=A8x,y=E2=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/fold.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/builtins/fold.c b/src/builtins/fold.c index 912c7e5f..4c847883 100644 --- a/src/builtins/fold.c +++ b/src/builtins/fold.c @@ -146,13 +146,25 @@ 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); usz ia = IA(x); - if (ia==0) { - decG(x); - if (isFun(f)) { - B r = TI(f,identity)(f); - if (!q_N(r)) return inc(r); + if (ia<=2) { + if (ia==2) { + SGet(x) + B x0 = Get(x,0); + B x1 = Get(x,1); + decG(x); + return c2(f, x0, x1); + } else if (ia==1) { + B r = IGet(x,0); + decG(x); + return r; + } else { + decG(x); + if (isFun(f)) { + B r = TI(f,identity)(f); + if (!q_N(r)) return inc(r); + } + thrM("´: No identity found"); } - thrM("´: No identity found"); } u8 xe = TI(x,elType); if (isFun(f) && v(f)->flags) {