diff options
-rw-r--r-- | apl9.h | 1 | ||||
-rw-r--r-- | operators.c | 13 |
2 files changed, 13 insertions, 1 deletions
@@ -367,6 +367,7 @@ Array *fnSelfReference2(Array *, Array *); /* Monadic operators from operators.c */ Array *opEach(Datum *, Array *, Array *); Array *opSwitch(Datum *, Array *, Array *); +Array *opKey(Datum *, Array *, Array *); Array *opOuterProduct(Datum *, Array *, Array *); Array *opSelfReference1(Datum *, Array *, Array *); diff --git a/operators.c b/operators.c index 8fd9911..202667c 100644 --- a/operators.c +++ b/operators.c @@ -10,7 +10,7 @@ Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙"; opmonad monadoperatordefs[] = { opEach, /* ¨ */ opSwitch, /* ⍨ */ - 0, /* ⌸ */ + opKey, /* ⌸ */ 0, /* ⌶ */ 0, /* & */ opOuterProduct, /* ⌾ */ @@ -80,6 +80,17 @@ opSwitch(Datum *lefto, Array *left, Array *right) } Array * +opKey(Datum *lefto, Array *left, Array *right) +{ + if(lefto->tag != FunctionTag) + throwerror(nil, EType); + if(left) + return rundfn(L"↑⍵∘(⍶{⍵⍶⍺⌷⍨⊂⍸⍹≡¨⍵}⍺)¨⊂¨∪⍺", lefto, nil, left, right); + else + return rundfn(L"⍵⍶⌸⍳≢⍵", lefto, nil, left, right); +} + +Array * opOuterProduct(Datum *lefto, Array *left, Array *right) { if(left == nil) |