From 31fcf0c2d8d229e3fc8e3813a611cf251247369d Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 4 Nov 2020 15:19:08 -0500 Subject: [PATCH] Try to skip double evaluations in list --- src/pebblisp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pebblisp.c b/src/pebblisp.c index 4d7e990..6ce55f3 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -197,13 +197,15 @@ Object listEvalLambda( env ); Object ret = eval(&lambda->lambda->body, &newEnv); + deleteEnv(&newEnv); cleanObject(lambda); Object *t = tail(&ret); if(t) { - // cleanObject(&ret); - return cloneObject(*t); + Object o = cloneObject(*t); + cleanObject(&ret); + return o; } return ret; } @@ -259,8 +261,13 @@ Object evalList(const Object *obj, struct Environment *env) default: { // Return list with each element evaluated Object list = listObject(); + int i = 0; + nf_addToList(&list, first_eval); FOR_POINTER_IN_LIST(obj) { - nf_addToList(&list, eval(POINTER, env)); + if(i != 0) { + nf_addToList(&list, eval(POINTER, env)); + } + i++; } return list; } @@ -491,7 +498,7 @@ Object print(Object p, Object ignore, struct Environment *env) p = cloneObject(p); p = eval(&p, env); _printObj(&p, 0); - return p; + return numberObject(0); } Object pChar(Object c, Object i1, struct Environment *i2)