No longer evals (x) to x

This commit is contained in:
Sage Vaillancourt 2020-11-03 14:44:37 -05:00
parent d8d8231f0d
commit 68705da88f
1 changed files with 6 additions and 4 deletions

View File

@ -81,9 +81,12 @@ Object evalMapArgs(const Object *argForms, struct Environment *env)
struct Environment newEnv = envForLambda(params, &tempList, env); struct Environment newEnv = envForLambda(params, &tempList, env);
// Add the lambda evaluation to the list // Add the lambda evaluation to the list
nf_addToList(&outputList, eval(&lambda.lambda->body, &newEnv)); Object lambda_output = eval(&lambda.lambda->body, &newEnv);
Object delisted = cloneObject(*lambda_output.list);
nf_addToList(&outputList, delisted);
deleteEnv(&newEnv); deleteEnv(&newEnv);
cleanObject(&tempList); cleanObject(&tempList);
cleanObject(&lambda_output);
} }
cleanObject(&lambda); cleanObject(&lambda);
@ -210,12 +213,11 @@ Object listEvalLambda(
* *
* Engages in several behaviors, depending on list contents: * Engages in several behaviors, depending on list contents:
* - () => () * - () => ()
* - (1item) => eval_1item // Questionable behavior! * - (x y z) => (eval_x eval_y eval_z)
* - (function x y) => evaluated function(x, y) * - (function x y) => evaluated function(x, y)
* - (function ...) => evaluated function(...) applied to each arg * - (function ...) => evaluated function(...) applied to each arg
* - (function x) => functionx() partial function * - (function x) => functionx() partial function
* - (lambda x) => evaluated lambda(x) * - (lambda x) => evaluated lambda(x)
* - (x y z) => (eval_x eval_y eval_z)
* *
* @param obj The list to be evaluated * @param obj The list to be evaluated
* @param env The environment to evaluate in * @param env The environment to evaluate in
@ -230,7 +232,7 @@ Object evalList(const Object *obj, struct Environment *env)
if(evalLength == 1) { if(evalLength == 1) {
if(listLength(obj->list) == 0) if(listLength(obj->list) == 0)
return cloneObject(*obj); return cloneObject(*obj);
return eval(obj->list, env); return startList(cloneObject(eval(obj->list, env)));
} }
Object *first_form = obj->list; Object *first_form = obj->list;