diff --git a/chapter12_functions.html b/chapter12_functions.html index 57be30f..254a8f0 100644 --- a/chapter12_functions.html +++ b/chapter12_functions.html @@ -286,15 +286,15 @@

Parent Environment


"Function '%s' passed too many arguments for symbols. " "Got %i, Expected %i.", func, syms->count, a->count-1); - for (int i = 0; i < syms->count; i++) { - /* If 'def' define in globally. If 'put' define in locally */ - if (strcmp(func, "def") == 0) { - lenv_def(e, syms->cell[i], a->cell[i+1]); - } - - if (strcmp(func, "=") == 0) { - lenv_put(e, syms->cell[i], a->cell[i+1]); - } + /* If 'def' define symbol globally. If 'put' define symbol locally */ + if (strcmp(func, "def") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_def(e, syms->cell[i], a->cell[i + 1]); + } + } else if (strcmp(func, "=") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_put(e, syms->cell[i], a->cell[i + 1]); + } } lval_del(a); diff --git a/src/conditionals.c b/src/conditionals.c index 698f642..640c1e1 100644 --- a/src/conditionals.c +++ b/src/conditionals.c @@ -513,9 +513,14 @@ lval* builtin_var(lenv* e, lval* a, char* func) { "Got %i, Expected %i.", func, syms->count, a->count-1); - for (int i = 0; i < syms->count; i++) { - if (strcmp(func, "def") == 0) { lenv_def(e, syms->cell[i], a->cell[i+1]); } - if (strcmp(func, "=") == 0) { lenv_put(e, syms->cell[i], a->cell[i+1]); } + if (strcmp(func, "def") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_def(e, syms->cell[i], a->cell[i + 1]); + } + } else if (strcmp(func, "=") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_put(e, syms->cell[i], a->cell[i + 1]); + } } lval_del(a); diff --git a/src/functions.c b/src/functions.c index b2dffcf..f1aecb2 100644 --- a/src/functions.c +++ b/src/functions.c @@ -489,15 +489,15 @@ lval* builtin_var(lenv* e, lval* a, char* func) { "Function '%s' passed too many arguments for symbols. " "Got %i, Expected %i.", func, syms->count, a->count-1); - for (int i = 0; i < syms->count; i++) { - /* If 'def' define in globally. If 'put' define in locally */ - if (strcmp(func, "def") == 0) { - lenv_def(e, syms->cell[i], a->cell[i+1]); - } - - if (strcmp(func, "=") == 0) { - lenv_put(e, syms->cell[i], a->cell[i+1]); - } + /* If 'def' define symbol globally. If 'put' define symbol locally */ + if (strcmp(func, "def") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_def(e, syms->cell[i], a->cell[i + 1]); + } + } else if (strcmp(func, "=") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_put(e, syms->cell[i], a->cell[i + 1]); + } } lval_del(a); diff --git a/src/hand_rolled_parser.c b/src/hand_rolled_parser.c index c923fd2..806951f 100644 --- a/src/hand_rolled_parser.c +++ b/src/hand_rolled_parser.c @@ -578,9 +578,14 @@ lval* builtin_var(lenv* e, lval* a, char* func) { "Got %i, Expected %i.", func, syms->count, a->count-1); - for (int i = 0; i < syms->count; i++) { - if (strcmp(func, "def") == 0) { lenv_def(e, syms->cell[i], a->cell[i+1]); } - if (strcmp(func, "=") == 0) { lenv_put(e, syms->cell[i], a->cell[i+1]); } + if (strcmp(func, "def") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_def(e, syms->cell[i], a->cell[i + 1]); + } + } else if (strcmp(func, "=") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_put(e, syms->cell[i], a->cell[i + 1]); + } } lval_del(a); diff --git a/src/strings.c b/src/strings.c index 85945c7..82391d7 100644 --- a/src/strings.c +++ b/src/strings.c @@ -542,9 +542,14 @@ lval* builtin_var(lenv* e, lval* a, char* func) { "Got %i, Expected %i.", func, syms->count, a->count-1); - for (int i = 0; i < syms->count; i++) { - if (strcmp(func, "def") == 0) { lenv_def(e, syms->cell[i], a->cell[i+1]); } - if (strcmp(func, "=") == 0) { lenv_put(e, syms->cell[i], a->cell[i+1]); } + if (strcmp(func, "def") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_def(e, syms->cell[i], a->cell[i + 1]); + } + } else if (strcmp(func, "=") == 0) { + for (int i = 0; i < syms->count; i++) { + lenv_put(e, syms->cell[i], a->cell[i + 1]); + } } lval_del(a);