summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/operators.c b/operators.c
index 8feda34..93f3b74 100644
--- a/operators.c
+++ b/operators.c
@@ -17,7 +17,7 @@ opmonad monadoperatordefs[] = {
};
opdyad dyadoperatordefs[] = {
- 0, /* ⍣ */
+ opPower, /* ⍣ */
0, /* . */
opBind, /* ∘ */
opAtop, /* ⍤ */
@@ -90,6 +90,16 @@ opSelfReference1(Datum *lefto, Array *left, Array *right)
/* Dyadic operators */
Array *
+opPower(Datum *lefto, Datum *righto, Array *left, Array *right)
+{
+ if(righto->tag != ArrayTag || righto->array->type != AtypeInt || righto->array->rank != 0 || righto->array->size != 1 || righto->array->intdata[0] < 0)
+ throwerror(nil, EDomain);
+ if(lefto->tag != FunctionTag)
+ throwerror(nil, EType);
+ return rundfn(L"⍺←⊢ ⋄ ⍹=0:⍵ ⋄ ⍺ ⍶⍙(⍹-1)⊢⍺⍶⍵", lefto, righto, left, right);
+}
+
+Array *
opBind(Datum *lefto, Datum *righto, Array *left, Array *right)
{
if(lefto->tag == FunctionTag && righto->tag == FunctionTag){