sys: make_list constructor

Takes a fixed array of lisp_t pointers, and makes a cons list out of
them.
This commit is contained in:
2026-03-05 19:59:23 +00:00
parent 2a13c89496
commit cb8d1b1139
2 changed files with 12 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ u64 sys_cost(sys_t *);
lisp_t *make_int(i64);
lisp_t *intern(sys_t *, sv_t);
lisp_t *cons(sys_t *, lisp_t *, lisp_t *);
lisp_t *make_list(sys_t *, lisp_t **, u64);
lisp_t *make_vec(sys_t *, u64);
lisp_t *make_str(sys_t *, u64);

View File

@@ -59,6 +59,17 @@ lisp_t *cons(sys_t *sys, lisp_t *car, lisp_t *cdr)
return cons;
}
lisp_t *make_list(sys_t *sys, lisp_t **lisps, u64 size)
{
lisp_t *root = NIL;
for (u64 i = size; i > 0; --i)
{
lisp_t *node = lisps[i - 1];
root = cons(sys, node, root);
}
return root;
}
lisp_t *make_vec(sys_t *sys, u64 capacity)
{
lisp_t *vec = sys_alloc(sys, TAG_VEC);