From b023a78ee6f7f6bcd1d100635a2b181d8b1af7a1 Mon Sep 17 00:00:00 2001 From: Dan Haffey Date: Wed, 3 Aug 2016 22:56:26 -0700 Subject: [PATCH] Fix jet discrepancies on ill-typed identity cases. --- jets/a/add.c | 5 ++++- jets/a/lth.c | 10 ++++++++-- jets/a/mul.c | 7 +++++-- jets/a/sub.c | 7 +++++-- jets/b/scag.c | 7 +++++-- jets/b/slag.c | 7 +++++-- jets/c/met.c | 13 +++++++------ jets/c/peg.c | 10 +++++++--- 8 files changed, 46 insertions(+), 20 deletions(-) diff --git a/jets/a/add.c b/jets/a/add.c index 3850c0ac5..0bcf608ee 100644 --- a/jets/a/add.c +++ b/jets/a/add.c @@ -15,6 +15,9 @@ return u3i_words(1, &c); } + else if ( 0 == a ) { + return u3k(b); + } else { mpz_t a_mp, b_mp; @@ -34,7 +37,7 @@ if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) + (c3n == u3ud(b) && a != 0) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/a/lth.c b/jets/a/lth.c index 5682aa803..afe5a62c7 100644 --- a/jets/a/lth.c +++ b/jets/a/lth.c @@ -13,6 +13,12 @@ if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { return __(a < b); } + else if ( 0 == a ) { + return c3y; + } + else if ( 0 == b ) { + return c3n; + } else { mpz_t a_mp, b_mp; u3_noun cmp; @@ -34,8 +40,8 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) + (c3n == u3ud(b) && a != 0) || + (c3n == u3ud(a) && b != 0) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/a/mul.c b/jets/a/mul.c index d48eea8d6..e8eacdbd4 100644 --- a/jets/a/mul.c +++ b/jets/a/mul.c @@ -15,6 +15,9 @@ return u3i_chubs(1, &c); } + else if ( 0 == a ) { + return 0; + } else { mpz_t a_mp, b_mp; @@ -34,7 +37,7 @@ if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) + (c3n == u3ud(b) && a != 0) ) { return u3m_bail(c3__exit); } else { @@ -42,7 +45,7 @@ } } u3_noun - u3ka_mul(u3_noun a, + u3ka_mul(u3_noun a, u3_noun b) { u3_noun c = u3qa_mul(a, b); diff --git a/jets/a/sub.c b/jets/a/sub.c index 90b26339c..7af71f96c 100644 --- a/jets/a/sub.c +++ b/jets/a/sub.c @@ -16,6 +16,9 @@ } else return (a - b); } + else if ( 0 == b ) { + return u3k(a); + } else { mpz_t a_mp, b_mp; @@ -41,8 +44,8 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) + (c3n == u3ud(b)) || + (c3n == u3ud(a) && b != 0) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/b/scag.c b/jets/b/scag.c index ad54b0d97..075497e58 100644 --- a/jets/b/scag.c +++ b/jets/b/scag.c @@ -10,7 +10,10 @@ u3qb_scag(u3_atom a, u3_noun b) { - if ( !_(u3a_is_cat(a)) ) { + if ( u3_nul == b ) { + return u3_nul; + } + else if ( !_(u3a_is_cat(a)) ) { return u3m_bail(c3__fail); } else { @@ -39,7 +42,7 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) ) + (c3n == u3ud(a) && u3_nul != b) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/b/slag.c b/jets/b/slag.c index 93736b65e..5a14b0beb 100644 --- a/jets/b/slag.c +++ b/jets/b/slag.c @@ -9,7 +9,10 @@ u3_noun u3qb_slag(u3_atom a, u3_noun b) { - if ( !_(u3a_is_cat(a)) ) { + if ( u3_nul == b ) { + return u3_nul; + } + else if ( !_(u3a_is_cat(a)) ) { return u3m_bail(c3__fail); } else { @@ -31,7 +34,7 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) ) + (c3n == u3ud(a) && u3_nul != b) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/c/met.c b/jets/c/met.c index 363319e25..ee9912602 100644 --- a/jets/c/met.c +++ b/jets/c/met.c @@ -10,10 +10,11 @@ u3qc_met(u3_atom a, u3_atom b) { - if ( !_(u3a_is_cat(a)) || (a >= 32) ) { - if ( 0 == b ) { - return 0; - } else return 1; + if ( 0 == b ) { + return 0; + } + else if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return 1; } else { c3_w met_w = u3r_met(a, b); @@ -30,8 +31,8 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) + (c3n == u3ud(b)) || + (c3n == u3ud(a) && 0 != b) ) { return u3m_bail(c3__exit); } else { diff --git a/jets/c/peg.c b/jets/c/peg.c index d8ec214f6..f55696a26 100644 --- a/jets/c/peg.c +++ b/jets/c/peg.c @@ -10,6 +10,10 @@ u3qc_peg(u3_atom a, u3_atom b) { + if ( 1 == b ) { + return u3k(a); + } + u3_atom c, d, e, f, g, h; c = u3r_met(0, b); @@ -33,10 +37,10 @@ u3_noun a, b; if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || (0 == a) || - (0 == b) ) + (0 == b) || + (c3n == u3ud(b)) || + (c3n == u3ud(a) && b != 1) ) { return u3m_bail(c3__exit); } else {