summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/operators.c b/operators.c
index 32b9074..05eed7d 100644
--- a/operators.c
+++ b/operators.c
@@ -19,7 +19,7 @@ opdyad dyadoperatordefs[] = {
0, /* ⍣ */
0, /* . */
opBind, /* ∘ */
- 0, /* ⍤ */
+ opAtop, /* ⍤ */
opOver, /* ⍥ */
0, /* @ */
0, /* ⍠ */
@@ -96,6 +96,53 @@ opBind(Datum *lefto, Datum *righto, Array *left, Array *right)
}
Array *
+opAtop(Datum *lefto, Datum *righto, Array *left, Array *right)
+{
+ if(lefto->tag == FunctionTag && righto->tag == FunctionTag){
+ Array *right1;
+ if(left)
+ right1 = runfunc(righto->func, left, right);
+ else
+ right1 = runfunc(righto->func, nil, right);
+ Array *result = runfunc(lefto->func, nil, right1);
+ freearray(right1);
+ return result;
+ }else if(lefto->tag == FunctionTag && righto->tag == ArrayTag){
+ Array *ranks = righto->array;
+ if(ranks->rank > 1)
+ throwerror(nil, ERank);
+ if(ranks->type != AtypeInt)
+ throwerror(nil, EType);
+ if(ranks->size < 1 || ranks->size > 3)
+ throwerror(nil, ELength);
+ int p,q,r;
+ switch(ranks->size){
+ case 1: p = q = r = ranks->intdata[0]; break;
+ case 2:
+ q = ranks->intdata[0];
+ p = r = ranks->intdata[1];
+ break;
+ case 3:
+ p = ranks->intdata[0];
+ q = ranks->intdata[1];
+ r = ranks->intdata[2];
+ break;
+ default:
+ p = q = r = 0;
+ }
+ print("Running %S with ranks %d %d %d\n", ppdatum(*lefto), p, q, r);
+ if(left)
+ throwerror(nil, ENotImplemented);
+ else{
+
+ }
+ throwerror(nil, ENotImplemented);
+ return nil;
+ }else
+ return nil;
+}
+
+Array *
opOver(Datum *lefto, Datum *righto, Array *left, Array *right)
{
if(lefto->tag != FunctionTag || righto->tag != FunctionTag)