summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/operators.c b/operators.c
index f6066d9..a06b0d6 100644
--- a/operators.c
+++ b/operators.c
@@ -4,7 +4,7 @@
#include "apl9.h"
-Rune primmonopnames[] = L"¨⍨⌸⌶&⌾∆";
+Rune primmonopnames[] = L"¨⍨⌸⌶&⌾∆⍇";
Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙";
opmonad monadoperatordefs[] = {
@@ -12,9 +12,10 @@ opmonad monadoperatordefs[] = {
opSwitch, /* ⍨ */
opKey, /* ⌸ */
0, /* ⌶ */
- 0, /* & */
+ opSpawn, /* & */
opOuterProduct, /* ⌾ */
opSelfReference1, /* ∆ */
+ opReceive, /* ⍇ */
};
opdyad dyadoperatordefs[] = {
@@ -68,7 +69,7 @@ Array *
opSwitch(Datum *lefto, Array *left, Array *right)
{
if(lefto->tag == ArrayTag){
- incref(lefto->array);
+ incarrayref(lefto->array);
return lefto->array;
}else if(lefto->tag == FunctionTag){
if(left)
@@ -91,6 +92,15 @@ opKey(Datum *lefto, Array *left, Array *right)
}
Array *
+opSpawn(Datum *lefto, Array *left, Array *right)
+{
+ if(lefto->tag != FunctionTag)
+ throwerror(L"Can only spawn functions", EType);
+ int id = spawnthread(lefto->func, left, right);
+ return mkscalarint(id);
+}
+
+Array *
opOuterProduct(Datum *lefto, Array *left, Array *right)
{
if(left == nil)
@@ -140,6 +150,19 @@ opSelfReference1(Datum *lefto, Array *left, Array *right)
}
}
+Array *
+opReceive(Datum *lefto, Array *left, Array *right)
+{
+ if(lefto->tag != FunctionTag)
+ throwerror(nil, EType);
+ if(right->type != AtypeInt)
+ throwerror(nil, EType);
+ if(right->size != 1)
+ throwerror(nil, ELength);
+ USED(left);
+ return messagerecv(lefto->func, right->intdata[0]);
+}
+
/* Dyadic operators */
Array *
opPower(Datum *lefto, Datum *righto, Array *left, Array *right)