commit 15c7c51e9fd4d6794779d32fa409c4326c0f07b5
parent c1c14eacf0133b890659b0a205f4d4cb539192de
Author: Ed van Bruggen <edvb@uw.edu>
Date: Sun, 2 Jun 2019 10:40:30 -0700
Allow equality test of different numbers
Diffstat:
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -183,19 +183,15 @@ list_last(Val v)
static int
vals_eq(Val a, Val b)
{
- if (a->t != b->t)
- return 0;
- switch (a->t) {
- case INTEGER:
- case DECIMAL:
- case RATIO:
+ if (a->t & NUMBER && b->t & NUMBER) {
if (num(a) != num(b) || den(a) != den(b))
return 0;
- break;
- default: /* PRIMITIVE, STRING, SYMBOL */
- if (a != b)
- return 0;
+ return 1;
}
+ if (a->t != b->t)
+ return 0;
+ if (a != b) /* PRIMITIVE, STRING, SYMBOL */
+ return 0;
return 1;
}