summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/eval.c b/src/eval.c
index a99ad4d..8ffe965 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -256,19 +256,22 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) {
}
}
else if (hash == get_hash("print")) {
- sym_t* v = eval(symbol->args[0], symbolScope);
- if (v->litType == INT) {
- printf("%d\n", symtoi(v));
- }
- else if (v->litType == FLOAT) {
- printf("%.5f\n", symtof(v));
- }
- else if (v->litType == STRING) {
- char* s = symtos(v);
- printf("%s\n", s);
- free(s);
+ for (int i = 0; i < symbol->argCount; i++) {
+ sym_t* v = eval(symbol->args[i], symbolScope);
+ if (v->litType == INT) {
+ printf("%d", symtoi(v));
+ }
+ else if (v->litType == FLOAT) {
+ printf("%.5f", symtof(v));
+ }
+ else if (v->litType == STRING) {
+ char* s = symtos(v);
+ printf("%s", s);
+ free(s);
+ }
+ destroy_sym(v);
}
- destroy_sym(v);
+ printf("\n");
return init_sym_int(1);
}
else {