+ return eval_success(atom_as_expr(create_number_atom(gc, result)));
+}
+
+static struct EvalResult call_callable(Gc *gc,
+ struct Scope *scope,
+ struct Expr callable,
+ struct Expr args) {
+ if (!callable_p(callable)) {
+ return eval_failure(CONS(gc,
+ SYMBOL(gc, "expected-callable"),
+ callable));
+ }
+
+ if (!list_p(args)) {
+ return eval_failure(CONS(gc,
+ SYMBOL(gc, "expected-list"),
+ args));
+ }
+
+ struct Expr vars = callable.cons->cdr.cons->car;
+
+ if (length_of_list(args) != length_of_list(vars)) {
+ return eval_failure(CONS(gc,
+ SYMBOL(gc, "wrong-number-of-arguments"),
+ NUMBER(gc, length_of_list(args))));
+ }
+
+ push_scope_frame(gc, scope, vars, args);
+ struct Expr body = callable.cons->cdr.cons->cdr;
+
+ struct EvalResult result = eval_success(NIL(gc));
+
+ while (!nil_p(body)) {
+ print_expr_as_sexpr(body.cons->car);
+ result = eval(gc, scope, body.cons->car);
+ if (result.is_error) {
+ return result;
+ }
+ body = body.cons->cdr;
+ }
+
+ pop_scope_frame(gc, scope);
+
+ return result;