Add printl, car, cdr builtins
This commit is contained in:
@@ -160,6 +160,13 @@ LISP_FUNC_1(ucl_builtin_print, state, arg0) {
|
|||||||
return ucl_nil_create();
|
return ucl_nil_create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LISP_FUNC_1(ucl_builtin_printl, state, arg0) {
|
||||||
|
ucl_print_obj(arg0);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return ucl_nil_create();
|
||||||
|
}
|
||||||
|
|
||||||
struct ucl_object *ucl_builtin_list(struct ucl_state *state, struct ucl_object *args) {
|
struct ucl_object *ucl_builtin_list(struct ucl_state *state, struct ucl_object *args) {
|
||||||
struct ucl_object *head = ucl_nil_create();
|
struct ucl_object *head = ucl_nil_create();
|
||||||
FOREACH_LIST(args, iter, item) {
|
FOREACH_LIST(args, iter, item) {
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ struct ucl_object *ucl_builtin_concat(struct ucl_state *state, struct ucl_object
|
|||||||
|
|
||||||
struct ucl_object *ucl_builtin_now_millis_mono(struct ucl_state *state, struct ucl_object *args);
|
struct ucl_object *ucl_builtin_now_millis_mono(struct ucl_state *state, struct ucl_object *args);
|
||||||
|
|
||||||
|
struct ucl_object *ucl_builtin_car(struct ucl_state *state, struct ucl_object *args);
|
||||||
|
struct ucl_object *ucl_builtin_cdr(struct ucl_state *state, struct ucl_object *args);
|
||||||
struct ucl_object *ucl_builtin_list(struct ucl_state *state, struct ucl_object *args);
|
struct ucl_object *ucl_builtin_list(struct ucl_state *state, struct ucl_object *args);
|
||||||
struct ucl_object *ucl_builtin_print(struct ucl_state *state, struct ucl_object *args);
|
struct ucl_object *ucl_builtin_print(struct ucl_state *state, struct ucl_object *args);
|
||||||
|
struct ucl_object *ucl_builtin_printl(struct ucl_state *state, struct ucl_object *args);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ int main(int argc, const char **argv) {
|
|||||||
// - iteration
|
// - iteration
|
||||||
|
|
||||||
ucl_state_put(state, "print", ucl_builtin_create(ucl_builtin_print));
|
ucl_state_put(state, "print", ucl_builtin_create(ucl_builtin_print));
|
||||||
|
ucl_state_put(state, "printl", ucl_builtin_create(ucl_builtin_printl));
|
||||||
ucl_state_put(state, "list", ucl_builtin_create(ucl_builtin_list));
|
ucl_state_put(state, "list", ucl_builtin_create(ucl_builtin_list));
|
||||||
// TODO:
|
// TODO:
|
||||||
// - print with newline
|
|
||||||
// - object -> string
|
// - object -> string
|
||||||
// - formatted printing?
|
// - formatted printing?
|
||||||
|
|
||||||
@@ -47,12 +47,12 @@ int main(int argc, const char **argv) {
|
|||||||
ucl_state_put(state, "string-p", ucl_builtin_create(ucl_builtin_string_p));
|
ucl_state_put(state, "string-p", ucl_builtin_create(ucl_builtin_string_p));
|
||||||
ucl_state_put(state, "int-p", ucl_builtin_create(ucl_builtin_int_p));
|
ucl_state_put(state, "int-p", ucl_builtin_create(ucl_builtin_int_p));
|
||||||
ucl_state_put(state, "list-p", ucl_builtin_create(ucl_builtin_list_p));
|
ucl_state_put(state, "list-p", ucl_builtin_create(ucl_builtin_list_p));
|
||||||
|
ucl_state_put(state, "car", ucl_builtin_create(ucl_builtin_car));
|
||||||
|
ucl_state_put(state, "cdr", ucl_builtin_create(ucl_builtin_cdr));
|
||||||
// TODO:
|
// TODO:
|
||||||
// - equality
|
// - equality
|
||||||
// - map
|
// - map
|
||||||
// - reduce
|
// - reduce
|
||||||
// - car
|
|
||||||
// - cdr
|
|
||||||
// - nth
|
// - nth
|
||||||
// - booleans (e.g. not)
|
// - booleans (e.g. not)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user