diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 18:58:45 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 18:58:45 +0000 |
commit | 07fe0f96352967457d64ff349f4383c5568bcd42 (patch) | |
tree | ca598c01a412c9af15e530b9ec22de8adbaab48c /functions.c | |
parent | 65bae1869f1451253276e51fea5b808b38685bf9 (diff) |
Implement Dop's
Diffstat (limited to 'functions.c')
-rw-r--r-- | functions.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/functions.c b/functions.c index bc71fb9..37cafa1 100644 --- a/functions.c +++ b/functions.c @@ -126,8 +126,15 @@ Array * runfunc(Function f, Array *left, Array *right) { Array *result; - if(f.type == FunctypeDfn){ - pushdfnframe(f.dfn); + if(f.type == FunctypeDfn || (f.type == FunctypeOp && f.operator.type == OperatortypeDop)){ + Rune *code; + if(f.type == FunctypeDfn) + code = f.dfn; + else{ + code = f.operator.dop; + } + + pushdfnframe(code); if(left){ Symbol *alpha = getsym(L"⍺", 1); alpha->value.tag = ArrayTag; @@ -142,7 +149,17 @@ runfunc(Function f, Array *left, Array *right) omega->undefined = 0; incref(right); - Datum *dfnres = evalline(f.dfn, nil, 0); + if(f.type == FunctypeOp){ + if(f.operator.dyadic){ + Symbol *omegaop = getsym(L"⍹", 1); + omegaop->value = *f.operator.right; + omegaop->undefined = 0; + } + Symbol *alphaop = getsym(L"⍶", 1); + alphaop->value = *f.operator.left; + alphaop->undefined = 0; + } + Datum *dfnres = evalline(code, nil, 0); popdfnframe(); result = (*dfnres).array; /* TODO what if the evaluation failed */ }else if(f.type == FunctypePrim){ |