summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-02-01 16:29:14 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-02-01 16:29:14 +0000
commit1dd3378ab8fccb5f6f33ebc781a95010bd6394b8 (patch)
treeb1f8f0afb29a7bee44e9332ccc2315c9fe405983 /functions.c
parent68d8437658cd000256ab135526e09590af4bf6c5 (diff)
Add some extra cases to be able to run the code from the video: 'Depth-first search in APL'
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/functions.c b/functions.c
index df90cf4..24fefa9 100644
--- a/functions.c
+++ b/functions.c
@@ -441,6 +441,11 @@ fnUniqueMask(Array *right)
res->intdata[0] = 1;
return res;
}
+ if(right->size == 0){
+ Array *res = allocarray(AtypeInt, 1, 0);
+ res->shape[0] = 0;
+ return res;
+ }
return rundfn(L"(⍳≢⍵)≤⊃∘⍸¨↓≡⌾⍨⌷∘⍵¨⍳≢⍵", nil, nil, nil, right);
}
@@ -1500,6 +1505,12 @@ fnIntervalIndex(Array *left, Array *right)
Array *
fnMembership(Array *left, Array *right)
{
+ if(right->size == 0)
+ return rundfn(L"(⍴⍵)⍴0", nil, nil, nil, left);
+
+ if(right->rank == 0)
+ return rundfn(L"⍺∊,⍵", nil, nil, left, right);
+
/* TODO avoid outer product */
return rundfn(L"∨/⍺≡⌾⍵", nil, nil, left, right);
}