summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c13
1 files changed, 12 insertions, 1 deletions
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)