From e6aeef5e54759c26912c4987cb86b3add2d77349 Mon Sep 17 00:00:00 2001 From: Felix Perktold Date: Tue, 13 Jan 2026 14:16:10 +0100 Subject: added some lisp functions --- lisp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp.c') diff --git a/lisp.c b/lisp.c index a559330..4e143f1 100644 --- a/lisp.c +++ b/lisp.c @@ -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; } -- cgit v1.2.3