summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/operators.c b/operators.c
index 5359a54..20c8611 100644
--- a/operators.c
+++ b/operators.c
@@ -4,15 +4,14 @@
#include "apl9.h"
-Rune primmonopnames[] = L"¨⍨⌸⌶&⌾∆⍇";
-Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙";
+Rune primmonopnames[] = L"¨⍨⌸⌶⌾∆⍇";
+Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙&";
opmonad monadoperatordefs[] = {
opEach, /* ¨ */
opSwitch, /* ⍨ */
opKey, /* ⌸ */
0, /* ⌶ */
- opSpawn, /* & */
opOuterProduct, /* ⌾ */
opSelfReference1, /* ∆ */
opReceive, /* ⍇ */
@@ -30,6 +29,7 @@ opdyad dyadoperatordefs[] = {
opUnder, /* ⍢ */
opObverse, /* ⍫ */
opSelfReference2, /* ⍙ */
+ opSpawn, /* & */
};
/* Monadic operators */
@@ -94,15 +94,6 @@ 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", ESyntax);
- int id = spawnthread(lefto->func, left, right);
- return mkscalarint(id);
-}
-
-Array *
opOuterProduct(Datum *lefto, Array *left, Array *right)
{
if(left == nil)
@@ -370,4 +361,17 @@ opSelfReference2(Datum *lefto, Datum *righto, Array *left, Array *right)
throwerror(nil, ESyntax);
return nil;
}
+}
+
+Array *
+opSpawn(Datum *lefto, Datum *righto, Array *left, Array *right)
+{
+ if(lefto->tag != FunctionTag)
+ throwerror(L"Can only spawn functions", ESyntax);
+ if(righto->tag != ArrayTag
+ || GetType(righto->array) != AtypeRune
+ || GetRank(righto->array) != 1)
+ throwerror(L"Thread name must be a character vector", EDomain);
+ int id = spawnthread(lefto->func, righto->array, left, right);
+ return mkscalarint(id);
} \ No newline at end of file