diff options
-rw-r--r-- | hybrids.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -166,9 +166,6 @@ fnExpandFirst(Array *left, Array *right) Array * opReduceLast(Datum *lefto, Array *left, Array *right) { - if(left) - throwerror(L"left argument to f/", ENotImplemented); - right = fnTranspose(right); Array *tmp = opReduceFirst(lefto, left, right); Array *res = fnTranspose(tmp); @@ -194,8 +191,21 @@ opScanLast(Datum *lefto, Array *left, Array *right) Array * opReduceFirst(Datum *lefto, Array *left, Array *right) { - if(left) - throwerror(L"left argument to f⌿", ENotImplemented); + if(left){ + if(left->type != AtypeInt) + throwerror(nil, EType); + if(left->size != 1) + throwerror(nil, ELength); + vlong winsize = left->intdata[0]; + if(winsize > right->shape[0]) + throwerror(nil, EShape); + + Rune *code = L"n←(-|⍺)+1+≢⍵ ⋄" + L"ix←(⍳|⍺)∘+¨(⍳n)-⎕io ⋄" + L"ix←⍺{⍺<0:⌽¨⍵ ⋄ ⍵}ix ⋄" + L"↑⍵∘(⍶{⍶⌿(⊂⍵)⌷⍺})¨ix"; + return rundfn(code, lefto, nil, left, right); + } if(right->rank == 0) return fnSame(right); |