From b84a2d4e1f2aa5ecd153e60714e2f0896efbd7b5 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 14 Sep 2022 15:42:21 -0400 Subject: [PATCH] Special-casing for length 1 in self-search functions --- src/builtins/selfsearch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builtins/selfsearch.c b/src/builtins/selfsearch.c index 7dcb30cc..37e647fd 100644 --- a/src/builtins/selfsearch.c +++ b/src/builtins/selfsearch.c @@ -6,7 +6,7 @@ B memberOf_c1(B t, B x) { if (isAtm(x) || RNK(x)==0) thrM("∊: Argument cannot have rank 0"); usz n = *SH(x); - if (n==0) { decG(x); return emptyIVec(); } + if (n<=1) { decG(x); return n ? taga(arr_shVec(allOnes(1))) : emptyIVec(); } u8 lw = cellWidthLog(x); void* xv = tyany_ptr(x); @@ -92,7 +92,7 @@ B memberOf_c1(B t, B x) { B count_c1(B t, B x) { if (isAtm(x) || RNK(x)==0) thrM("⊒: Argument cannot have rank 0"); usz n = *SH(x); - if (n==0) { decG(x); return emptyIVec(); } + if (n<=1) { decG(x); return n ? taga(arr_shVec(allZeroes(1))) : emptyIVec(); } if (n>(usz)I32_MAX+1) thrM("⊒: Argument length >2⋆31 not supported"); u8 lw = cellWidthLog(x); @@ -184,7 +184,7 @@ extern B rt_indexOf; B indexOf_c1(B t, B x) { if (isAtm(x) || RNK(x)==0) thrM("⊐: 𝕩 cannot have rank 0"); usz n = *SH(x); - if (n==0) { decG(x); return emptyIVec(); } + if (n<=1) { decG(x); return n ? taga(arr_shVec(allZeroes(1))) : emptyIVec(); } if (n>(usz)I32_MAX+1) thrM("⊐: Argument length >2⋆31 not supported"); u8 lw = cellWidthLog(x);