Add mapcar builtin, more tests, fixes
This commit is contained in:
@@ -182,3 +182,15 @@ struct ucl_object *ucl_builtin_list(struct ucl_state *state, struct ucl_object *
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_mapcar, state, fun, elems) {
|
||||
// TODO: Support arbitrary number of 'elems' lists
|
||||
struct ucl_object *result = ucl_nil_create();
|
||||
FOREACH_LIST(elems, iter, elem) {
|
||||
struct ucl_object *form = ucl_tuple_create(fun, elem);
|
||||
struct ucl_object *value = ucl_evaluate(state, form);
|
||||
UCL_RET_IF_ERROR(value);
|
||||
ucl_list_append(result, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user