From 1f7034c0c2c6c94108f36a1701237c3549963a89 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Wed, 16 Nov 2022 21:38:41 -0500 Subject: [PATCH] Add append, add 'equal' to repl --- src/builtins.c | 5 +++++ src/builtins.h | 3 +++ src/main.c | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/builtins.c b/src/builtins.c index c00801e..c662e37 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -238,3 +238,8 @@ LISP_FUNC_2(ucl_builtin_xor, scope, arg0, arg1) { LISP_FUNC_1(ucl_builtin_not, scope, arg0) { return ucl_predicate(!ucl_truthy_bool(arg0)); } + +LISP_FUNC_2(ucl_builtin_append, scope, list, elem) { + ucl_list_append(list, elem); + return list; +} diff --git a/src/builtins.h b/src/builtins.h index 889acdb..05778b3 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -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_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_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_printl(struct ucl_scope *scope, struct ucl_object *args); +struct ucl_object *ucl_builtin_equal(struct ucl_scope *scope, struct ucl_object *args); + #endif diff --git a/src/main.c b/src/main.c index dc0f4d4..eefbdcc 100644 --- a/src/main.c +++ b/src/main.c @@ -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, "nth", ucl_builtin_create(ucl_builtin_nth)); 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, "dolist", ucl_special_create(ucl_special_dolist)); @@ -68,6 +69,7 @@ int main(int argc, const char **argv) { // TODO: // - reduce + // - filter if (argc < 2) { while (1) {