Try to skip double evaluations in list
This commit is contained in:
parent
9da87f5674
commit
31fcf0c2d8
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue