diff options
| author | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2026-01-13 14:16:10 +0100 |
|---|---|---|
| committer | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2026-01-13 14:16:10 +0100 |
| commit | e6aeef5e54759c26912c4987cb86b3add2d77349 (patch) | |
| tree | 70a010f6e9d7dbacedbace1bb07e3f252b3305c0 /lisp.c | |
| parent | 3dbec6aa8759461e00e6b5fabaf92fbf68379118 (diff) | |
added some lisp functions
Diffstat (limited to 'lisp.c')
| -rw-r--r-- | lisp.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -222,7 +222,7 @@ value *eval(env *e, value *v) { if (!found) { printf("symbol %s not found\n", v->as.sym); return cons(make_symbol("quote"), - cons(v, make_nil())); + cons(v, make_nil())); //TODO: return error } return found; } @@ -318,9 +318,13 @@ value *apply(value *lval, value *args) { value *result = eval(sub_env, lval->as.lambda.body); // if arguments left, try applying them to evaluated lambda - if (arg->type == VT_PAIR) { + if (arg->type == VT_PAIR && result->type == VT_LAMBDA) { return apply(result, arg); } + // if arguments left but result is not a lambda, explicitely return false TODO: return an error + if (arg->type == VT_PAIR) { + return make_nil(); + } return result; } |
