From 1bf60c0cfc8e26d4f9e92e044d37169f55ac170b Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 25 Jan 2022 17:05:41 +0000 Subject: Get ready for inverse of functions --- operators.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'operators.c') diff --git a/operators.c b/operators.c index 17ba76e..1ecb8aa 100644 --- a/operators.c +++ b/operators.c @@ -101,8 +101,14 @@ opPower(Datum *lefto, Datum *righto, Array *left, Array *right) else code = L"next←⍶⍵ ⋄ next⍹⍵:⍵ ⋄ ∇next"; }else if(righto->tag == ArrayTag){ - if(righto->array->type != AtypeInt || righto->array->rank != 0 || righto->array->size != 1 || righto->array->intdata[0] < 0) + if(righto->array->type != AtypeInt || righto->array->rank != 0 || righto->array->size != 1) throwerror(L"right operand to ⍣", EDomain); + vlong times = righto->array->intdata[0]; + if(times < 0){ + lefto->func = inverse(lefto->func); + times = -times; + } + righto->array->intdata[0] = times; if(left) code = L"⍹=0:⍵ ⋄ ⍺ ⍶⍙(⍹-1)⊢⍺⍶⍵"; else -- cgit v1.2.3