diff --git a/pkg/noun/jets/a/add.c b/pkg/noun/jets/a/add.c index a84436bf04..94d262d748 100644 --- a/pkg/noun/jets/a/add.c +++ b/pkg/noun/jets/a/add.c @@ -6,7 +6,7 @@ #include "noun.h" -u3_noun +u3_atom u3qa_add(u3_atom a, u3_atom b) { @@ -31,16 +31,14 @@ u3qa_add(u3_atom a, } } -u3_noun +u3_weak u3wa_add(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b) && a != 0) ) - { - return u3m_bail(c3__exit); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } else { return u3qa_add(a, b); diff --git a/pkg/noun/jets/a/gte.c b/pkg/noun/jets/a/gte.c index 8934ec5c5b..e58b83a67a 100644 --- a/pkg/noun/jets/a/gte.c +++ b/pkg/noun/jets/a/gte.c @@ -5,7 +5,7 @@ #include "noun.h" -u3_noun +u3_atom u3qa_gte(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { @@ -26,7 +26,7 @@ u3qa_gte(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun cmp; + u3_atom cmp; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -41,18 +41,14 @@ u3qa_gte(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_gte(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_gte(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_gte(a, b); } diff --git a/pkg/noun/jets/a/gth.c b/pkg/noun/jets/a/gth.c index 5b059e54aa..ad522c9093 100644 --- a/pkg/noun/jets/a/gth.c +++ b/pkg/noun/jets/a/gth.c @@ -6,7 +6,7 @@ #include "noun.h" -u3_noun +u3_atom u3qa_gth(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { @@ -27,7 +27,7 @@ u3qa_gth(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun cmp; + u3_atom cmp; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -42,26 +42,22 @@ u3qa_gth(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_gth(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_gth(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_gth(a, b); } -u3_noun -u3ka_gth(u3_noun a, u3_noun b) +u3_atom +u3ka_gth(u3_atom a, u3_atom b) { - u3_noun c = u3qa_gth(a, b); + u3_atom c = u3qa_gth(a, b); u3z(a); u3z(b); return c; } diff --git a/pkg/noun/jets/a/lte.c b/pkg/noun/jets/a/lte.c index 4def610c01..1d62b2d72f 100644 --- a/pkg/noun/jets/a/lte.c +++ b/pkg/noun/jets/a/lte.c @@ -6,7 +6,7 @@ #include "noun.h" -u3_noun +u3_atom u3qa_lte(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { @@ -27,7 +27,7 @@ u3qa_lte(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun cmp; + u3_atom cmp; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -42,26 +42,22 @@ u3qa_lte(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_lte(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_lte(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_lte(a, b); } -u3_noun -u3ka_lte(u3_noun a, u3_noun b) +u3_atom +u3ka_lte(u3_atom a, u3_atom b) { - u3_noun c = u3qa_lte(a, b); + u3_atom c = u3qa_lte(a, b); u3z(a); u3z(b); return c; } diff --git a/pkg/noun/jets/a/lth.c b/pkg/noun/jets/a/lth.c index 0e74a797d2..3da15609ff 100644 --- a/pkg/noun/jets/a/lth.c +++ b/pkg/noun/jets/a/lth.c @@ -5,7 +5,7 @@ #include "noun.h" -u3_noun +u3_atom u3qa_lth(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { @@ -26,7 +26,7 @@ u3qa_lth(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun cmp; + u3_atom cmp; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -41,18 +41,14 @@ u3qa_lth(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_lth(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_lth(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_lth(a, b); } diff --git a/pkg/noun/jets/a/max.c b/pkg/noun/jets/a/max.c index 929ee501d4..46f255d7cb 100644 --- a/pkg/noun/jets/a/max.c +++ b/pkg/noun/jets/a/max.c @@ -6,13 +6,15 @@ #include "noun.h" -u3_noun +u3_atom u3qa_max(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { - return u3k(c3_max(a, b)); + return c3_max(a, b); } else { + if ( a == 0 ) return u3k(b); + if ( b == 0 ) return u3k(a); c3_w a_w = u3r_met(0, a); c3_w b_w = u3r_met(0, b); @@ -21,7 +23,7 @@ u3qa_max(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun max; + u3_atom max; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -36,26 +38,22 @@ u3qa_max(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_max(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_max(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_max(a, b); } -u3_noun -u3ka_max(u3_noun a, u3_noun b) +u3_atom +u3ka_max(u3_atom a, u3_atom b) { - u3_noun c = u3qa_max(a, b); + u3_atom c = u3qa_max(a, b); u3z(a); u3z(b); return c; } diff --git a/pkg/noun/jets/a/min.c b/pkg/noun/jets/a/min.c index 243c50bb6e..af93e10d7e 100644 --- a/pkg/noun/jets/a/min.c +++ b/pkg/noun/jets/a/min.c @@ -6,13 +6,16 @@ #include "noun.h" -u3_noun +u3_atom u3qa_min(u3_atom a, u3_atom b) { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { - return u3k(c3_min(a, b)); + return c3_min(a, b); } else { + if ( (a == 0) || (b == 0) ) { + return 0; + } c3_w a_w = u3r_met(0, a); c3_w b_w = u3r_met(0, b); @@ -21,7 +24,7 @@ u3qa_min(u3_atom a, u3_atom b) } else { mpz_t a_mp, b_mp; - u3_noun min; + u3_atom min; u3r_mp(a_mp, a); u3r_mp(b_mp, b); @@ -36,26 +39,22 @@ u3qa_min(u3_atom a, u3_atom b) } } -u3_noun +u3_weak u3wa_min(u3_noun cor) { u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) - || (c3n == u3ud(b) && 0 != a) - || (c3n == u3ud(a) && 0 != b) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qa_min(a, b); + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + if ( !_(u3ud(a)) || !_(u3ud(b)) ) { + return u3_none; } + return u3qa_min(a, b); } -u3_noun -u3ka_min(u3_noun a, u3_noun b) +u3_atom +u3ka_min(u3_atom a, u3_atom b) { - u3_noun c = u3qa_min(a, b); + u3_atom c = u3qa_min(a, b); u3z(a); u3z(b); return c; } diff --git a/pkg/noun/jets/b/sort.c b/pkg/noun/jets/b/sort.c index 9b01d5422f..711645a966 100644 --- a/pkg/noun/jets/b/sort.c +++ b/pkg/noun/jets/b/sort.c @@ -28,9 +28,12 @@ if ( c3y == hoz ) { nex = u3nc(u3nc(u3k(u3h(a)), u3k(u3h(acc))), u3k(u3t(acc))); } - else { + else if ( c3n == hoz ) { nex = u3nc(u3k(u3h(acc)), u3nc(u3k(u3h(a)), u3k(u3t(acc)))); } + else { + return u3m_bail(c3__exit); + } u3z(hoz); u3z(acc); diff --git a/pkg/noun/jets/c/swp.c b/pkg/noun/jets/c/swp.c index 1d0a11b434..4f503e7412 100644 --- a/pkg/noun/jets/c/swp.c +++ b/pkg/noun/jets/c/swp.c @@ -10,12 +10,16 @@ u3_noun u3qc_swp(u3_atom a, u3_atom b) { - c3_w len_w = u3r_met(a, b); + if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return u3m_bail(c3__fail); + } + c3_g a_g = a; + c3_w len_w = u3r_met(a_g, b); u3i_slab sab_u; - u3i_slab_init(&sab_u, a, len_w); + u3i_slab_init(&sab_u, a_g, len_w); for (c3_w i = 0; i < len_w; i++) { - u3r_chop(a, i, 1, len_w - i - 1, sab_u.buf_w, b); + u3r_chop(a_g, i, 1, len_w - i - 1, sab_u.buf_w, b); } return u3i_slab_mint(&sab_u); diff --git a/pkg/noun/jets/e/cue.c b/pkg/noun/jets/e/cue.c index 4ab89ba552..643b4082c9 100644 --- a/pkg/noun/jets/e/cue.c +++ b/pkg/noun/jets/e/cue.c @@ -15,7 +15,7 @@ u3qe_cue(u3_atom a) u3_noun u3we_cue(u3_noun cor) { - return u3qe_cue(u3x_at(u3x_sam, cor)); + return u3qe_cue(u3x_atom(u3x_at(u3x_sam, cor))); } u3_noun