diff --git a/src/pebblisp.c b/src/pebblisp.c index cbab1cc..4d7e990 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -81,9 +81,12 @@ Object evalMapArgs(const Object *argForms, struct Environment *env) struct Environment newEnv = envForLambda(params, &tempList, env); // 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); cleanObject(&tempList); + cleanObject(&lambda_output); } cleanObject(&lambda); @@ -210,12 +213,11 @@ Object listEvalLambda( * * 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 ...) => evaluated function(...) applied to each arg * - (function x) => functionx() partial function * - (lambda x) => evaluated lambda(x) - * - (x y z) => (eval_x eval_y eval_z) * * @param obj The list to be evaluated * @param env The environment to evaluate in @@ -230,7 +232,7 @@ Object evalList(const Object *obj, struct Environment *env) if(evalLength == 1) { if(listLength(obj->list) == 0) return cloneObject(*obj); - return eval(obj->list, env); + return startList(cloneObject(eval(obj->list, env))); } Object *first_form = obj->list;