Add append, add 'equal' to repl

This commit is contained in:
2022-11-16 21:38:41 -05:00
parent fd5aad95dc
commit 1f7034c0c2
3 changed files with 11 additions and 1 deletions

View File

@@ -238,3 +238,8 @@ LISP_FUNC_2(ucl_builtin_xor, scope, arg0, arg1) {
LISP_FUNC_1(ucl_builtin_not, scope, arg0) { LISP_FUNC_1(ucl_builtin_not, scope, arg0) {
return ucl_predicate(!ucl_truthy_bool(arg0)); return ucl_predicate(!ucl_truthy_bool(arg0));
} }
LISP_FUNC_2(ucl_builtin_append, scope, list, elem) {
ucl_list_append(list, elem);
return list;
}

View File

@@ -32,8 +32,11 @@ struct ucl_object *ucl_builtin_cdr(struct ucl_scope *scope, struct ucl_object *a
struct ucl_object *ucl_builtin_nth(struct ucl_scope *scope, struct ucl_object *args); struct ucl_object *ucl_builtin_nth(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_list(struct ucl_scope *scope, struct ucl_object *args); struct ucl_object *ucl_builtin_list(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_mapcar(struct ucl_scope *scope, struct ucl_object *args); struct ucl_object *ucl_builtin_mapcar(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_append(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_print(struct ucl_scope *scope, struct ucl_object *args); struct ucl_object *ucl_builtin_print(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_printl(struct ucl_scope *scope, struct ucl_object *args); struct ucl_object *ucl_builtin_printl(struct ucl_scope *scope, struct ucl_object *args);
struct ucl_object *ucl_builtin_equal(struct ucl_scope *scope, struct ucl_object *args);
#endif #endif

View File

@@ -60,7 +60,8 @@ int main(int argc, const char **argv) {
ucl_scope_put(scope, "cdr", ucl_builtin_create(ucl_builtin_cdr)); ucl_scope_put(scope, "cdr", ucl_builtin_create(ucl_builtin_cdr));
ucl_scope_put(scope, "nth", ucl_builtin_create(ucl_builtin_nth)); ucl_scope_put(scope, "nth", ucl_builtin_create(ucl_builtin_nth));
ucl_scope_put(scope, "mapcar", ucl_builtin_create(ucl_builtin_mapcar)); ucl_scope_put(scope, "mapcar", ucl_builtin_create(ucl_builtin_mapcar));
ucl_scope_put(scope, "equal", ucl_builtin_create(ucl_builtin_mapcar)); ucl_scope_put(scope, "equal", ucl_builtin_create(ucl_builtin_equal));
ucl_scope_put(scope, "append", ucl_builtin_create(ucl_builtin_append));
ucl_scope_put(scope, "dotimes", ucl_special_create(ucl_special_dotimes)); ucl_scope_put(scope, "dotimes", ucl_special_create(ucl_special_dotimes));
ucl_scope_put(scope, "dolist", ucl_special_create(ucl_special_dolist)); ucl_scope_put(scope, "dolist", ucl_special_create(ucl_special_dolist));
@@ -68,6 +69,7 @@ int main(int argc, const char **argv) {
// TODO: // TODO:
// - reduce // - reduce
// - filter
if (argc < 2) { if (argc < 2) {
while (1) { while (1) {