Add boolean, comparison, and equality functions
This commit is contained in:
@@ -105,3 +105,25 @@ struct ucl_object *ucl_special_progn(struct ucl_state *state, struct ucl_object
|
||||
struct ucl_object *ucl_special_quote(struct ucl_state *state, struct ucl_object *args) {
|
||||
return ucl_car(args);
|
||||
}
|
||||
|
||||
struct ucl_object *ucl_special_and(struct ucl_state *state, struct ucl_object *args) {
|
||||
struct ucl_object *value = ucl_t_create();
|
||||
FOREACH_LIST(args, iter, form) {
|
||||
value = ucl_evaluate(state, form);
|
||||
if (!ucl_truthy_bool(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
struct ucl_object *ucl_special_or(struct ucl_state *state, struct ucl_object *args) {
|
||||
struct ucl_object *value = ucl_nil_create();
|
||||
FOREACH_LIST(args, iter, form) {
|
||||
value = ucl_evaluate(state, form);
|
||||
if (ucl_truthy_bool(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user