From 55ca6248ffff6d9e1669fc49fe9de8489adeb7f9 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 12 Jan 2022 20:09:05 +0000 Subject: =?UTF-8?q?Add=20dfn=20evaluation,=20and=20localized=20=E2=8E=95IO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eval.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 4d0d497..3221b4c 100644 --- a/eval.c +++ b/eval.c @@ -150,10 +150,25 @@ monadfun(Datum left, Datum right) traceprint("Monadic function application\n"); Datum result; result.tag = ArrayTag; + result.shy = 0; if(left.func.type == FunctypeDfn){ - print("Can't evaluate dfns yet: %S %S\n", ppdatum(left), ppdatum(right)); - exits(nil); + Symtab *tmpsymtab = currentsymtab; + currentsymtab = newsymtab(); + if(left.func.left){ + Symbol *alpha = getsym(currentsymtab, L"⍺"); + alpha->value.tag = ArrayTag; + alpha->value.array = left.func.left; + alpha->undefined = 0; + } + + Symbol *omega = getsym(currentsymtab, L"⍵"); + omega->value = right; + omega->undefined = 0; + + Datum *dfnres = evalline(left.func.dfn); + currentsymtab = tmpsymtab; + return *dfnres; /* TODO what if the evaluation failed */ }else{ /* TODO handle undefined functions here */ if(left.func.left) -- cgit v1.2.3