summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/functions.c b/functions.c
index 2e95316..0013d8f 100644
--- a/functions.c
+++ b/functions.c
@@ -88,7 +88,7 @@ fndyad dyadfunctiondefs[] = {
fnGreater, /* > */
fnGreaterEqual, /* ≥ */
fnMatch, /* ≡ */
- 0, /* ≢ */
+ fnNotMatch, /* ≢ */
fnOr, /* ∨ */
fnAnd, /* ∧ */
fnNand, /* ⍲ */
@@ -146,7 +146,10 @@ runfunc(Function f, Array *left, Array *right)
popdfnframe();
result = dfnres->array; /* TODO what if the evaluation failed */
- incarrayref(result);
+ if(dfnres->tag != ArrayTag || result == nil)
+ result = mkscalarint(0); /* Very stupid */
+ else
+ incarrayref(result);
freedatum(dfnres);
}else if(f.type == FunctypePrim){
if(left){
@@ -1243,6 +1246,13 @@ fnMatch(Array *left, Array *right)
return mkscalarint(cmp == 0);
}
+Array *
+fnNotMatch(Array *left, Array *right)
+{
+ int cmp = comparearray(left, right, 1);
+ return mkscalarint(cmp != 0);
+}
+
SCALAR_FUNCTION_2(fnOr, 0, GetType(left),
case AtypeInt:
if((left->intdata[i] == 0 || left->intdata[i] == 1) && (right->intdata[i] == 0 || right->intdata[i] == 1))