Add boolean, comparison, and equality functions
This commit is contained in:
@@ -194,3 +194,46 @@ LISP_FUNC_2(ucl_builtin_mapcar, state, fun, elems) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_equal, state, arg0, arg1) {
|
||||
return ucl_equal(arg0, arg1);
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_gt, state, arg0, arg1) {
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "First argument to > must be an integer");
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "Second argument to > must be an integer");
|
||||
return ucl_predicate(arg0->integer > arg1->integer);
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_ge, state, arg0, arg1) {
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "First argument to >= must be an integer");
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "Second argument to >= must be an integer");
|
||||
return ucl_predicate(arg0->integer > arg1->integer);
|
||||
}
|
||||
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_lt, state, arg0, arg1) {
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "First argument to < must be an integer");
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "Second argument to < must be an integer");
|
||||
return ucl_predicate(arg0->integer < arg1->integer);
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_le, state, arg0, arg1) {
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "First argument to <= must be an integer");
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "Second argument to <= must be an integer");
|
||||
return ucl_predicate(arg0->integer < arg1->integer);
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_num_eq, state, arg0, arg1) {
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "First argument to = must be an integer");
|
||||
UCL_COND_OR_RET_ERROR(arg0->type == UCL_TYPE_INT, "Second argument to = must be an integer");
|
||||
return ucl_predicate(arg0->integer == arg1->integer);
|
||||
}
|
||||
|
||||
LISP_FUNC_2(ucl_builtin_xor, state, arg0, arg1) {
|
||||
return ucl_predicate(ucl_truthy_bool(arg0) || ucl_truthy_bool(arg1));
|
||||
}
|
||||
|
||||
LISP_FUNC_1(ucl_builtin_not, state, arg0) {
|
||||
return ucl_predicate(!ucl_truthy_bool(arg0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user