aboutsummaryrefslogtreecommitdiff
path: root/ell.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-21 12:07:21 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-21 13:19:49 +0200
commit5383dfac9cfc519c5f1651d18edb374d6fce4e6f (patch)
treeb74065a40ff7b30c061c2b7a1f9daab1a1f3fd3d /ell.c
parent04364b75eab3287bb18fe658f28d058f37dd690f (diff)
downloadell-5383dfac9cfc519c5f1651d18edb374d6fce4e6f.tar.gz
ell-5383dfac9cfc519c5f1651d18edb374d6fce4e6f.tar.xz
ell-5383dfac9cfc519c5f1651d18edb374d6fce4e6f.zip
Add "ne?", "ge?", "le?", "gt?"
At least in some form.
Diffstat (limited to 'ell.c')
-rwxr-xr-xell.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ell.c b/ell.c
index 8a46c6b..301d17e 100755
--- a/ell.c
+++ b/ell.c
@@ -1145,6 +1145,7 @@ defn (fn_not) {
return check (ctx, (*result = new_boolean (!truthy (args))));
}
+// TODO: "and" and "or" should be short-circuiting special forms
defn (fn_and) {
bool res = true;
for (; args; args = args->next)
@@ -1196,9 +1197,13 @@ init_runtime_library (struct context *ctx) {
const char *name; ///< Name of the function
const char *definition; ///< The defining script
} functions[] = {
- // TODO: try to think of something useful
// 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;