Add nth builtin

This commit is contained in:
2022-11-04 22:44:17 -04:00
parent a5ef5c9fa0
commit f9ace289f1
3 changed files with 9 additions and 1 deletions

View File

@@ -69,6 +69,13 @@ LISP_FUNC_1(ucl_builtin_cdr, state, arg) {
return ucl_cdr(arg);
}
LISP_FUNC_2(ucl_builtin_nth, state, n, list) {
UCL_COND_OR_RET_ERROR(n->type == UCL_TYPE_INT, "First argument to nth must be an integer");
UCL_COND_OR_RET_ERROR(list->type == UCL_TYPE_CELL, "Second argument to nth must be a list");
return ucl_list_nth(list, n->integer);
}
LISP_FUNC_2(ucl_builtin_add, state, arg0, arg1) {
if (arg0->type != UCL_TYPE_INT) {
return ucl_error_create("Invalid type of argument 0 to 'add'");