diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-25 17:05:41 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-25 17:05:41 +0000 |
commit | 1bf60c0cfc8e26d4f9e92e044d37169f55ac170b (patch) | |
tree | 0ddf8ac8d9c521d51bcfa7b6dad6ff1bb539fca9 /operators.c | |
parent | 580b7dd6b3590134e7be96ebf758a956926130a9 (diff) |
Get ready for inverse of functions
Diffstat (limited to 'operators.c')
-rw-r--r-- | operators.c | 8 |
1 files changed, 7 insertions, 1 deletions
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 |