diff options
author | glenda <glenda@cirno> | 2022-09-10 16:25:05 +0000 |
---|---|---|
committer | glenda <glenda@cirno> | 2022-09-10 16:25:05 +0000 |
commit | e2ebfbb7d19ff3b990eb51dc9843200053cbbf98 (patch) | |
tree | 986b0353a1179f803872b1578ebfe0acd83050bd /functions.c | |
parent | d07d4afcb8acff3757394f2f9822d014f31fecf0 (diff) |
Improve the session a lot
Diffstat (limited to 'functions.c')
-rw-r--r-- | functions.c | 14 |
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)) |