From 1dd3378ab8fccb5f6f33ebc781a95010bd6394b8 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 1 Feb 2022 16:29:14 +0000 Subject: Add some extra cases to be able to run the code from the video: 'Depth-first search in APL' --- functions.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); } -- cgit v1.2.3