Add "ne?", "ge?", "le?", "gt?"

At least in some form.
This commit is contained in:
Přemysl Eric Janouch 2017-05-21 12:07:21 +02:00
parent 04364b75ea
commit 5383dfac9c
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 7 additions and 2 deletions

9
ell.c
View File

@ -1145,6 +1145,7 @@ defn (fn_not) {
return check (ctx, (*result = new_boolean (!truthy (args)))); return check (ctx, (*result = new_boolean (!truthy (args))));
} }
// TODO: "and" and "or" should be short-circuiting special forms
defn (fn_and) { defn (fn_and) {
bool res = true; bool res = true;
for (; args; args = args->next) for (; args; args = args->next)
@ -1196,9 +1197,13 @@ init_runtime_library (struct context *ctx) {
const char *name; ///< Name of the function const char *name; ///< Name of the function
const char *definition; ///< The defining script const char *definition; ///< The defining script
} functions[] = { } functions[] = {
// TODO: try to think of something useful
// FIXME: this "unless" is probably not going to work // FIXME: this "unless" is probably not going to work
{ "unless", "arg cond body; if (not (eval @cond)) @body" }, { "unless", "arg _cond _body; if (not (eval @_cond)) @_body" },
// TODO: we should be able to apply them to all arguments
{ "ne?", "arg _ne1 _ne2; not (eq? @_ne1 @_ne2))" },
{ "ge?", "arg _ge1 _ge2; not (lt? @_ge1 @_ge2))" },
{ "le?", "arg _le1 _le2; ge? @_le2 @_le1" },
{ "gt?", "arg _gt1 _gt2; lt? @_gt2 @_gt1" },
}; };
bool ok = true; bool ok = true;