diff --git a/Makefile b/Makefile index 5fc8507cac..2fb42d5910 100644 --- a/Makefile +++ b/Makefile @@ -256,6 +256,7 @@ J_D_OFILES=\ jets/d/in_put.o \ jets/d/in_tap.o \ jets/d/in_uni.o \ + jets/d/in_wyt.o \ jets/d/in_bif.o \ jets/d/in_dif.o \ jets/d/by_gas.o \ diff --git a/include/jets/q.h b/include/jets/q.h index 993735faaf..e3c3b3a845 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -90,6 +90,7 @@ u3_noun u3qdi_put(u3_noun, u3_noun); u3_noun u3qdi_tap(u3_noun, u3_noun); u3_noun u3qdi_uni(u3_noun, u3_noun); + u3_noun u3qdi_wyt(u3_noun); /** Tier 5. **/ diff --git a/include/jets/w.h b/include/jets/w.h index 45d2cba320..ca58551a9f 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -95,6 +95,7 @@ u3_noun u3wdi_put(u3_noun); u3_noun u3wdi_tap(u3_noun); u3_noun u3wdi_uni(u3_noun); + u3_noun u3wdi_wyt(u3_noun); /** Tier 5. **/ diff --git a/jets/d/in_uni.c b/jets/d/in_uni.c index f8b49ff099..85f07b8350 100644 --- a/jets/d/in_uni.c +++ b/jets/d/in_uni.c @@ -3,6 +3,68 @@ */ #include "all.h" +/* internal functions +*/ + +static u3_noun +_in_uni(u3_noun a, u3_noun b) +{ + u3_noun n_a, l_a, r_a, + n_b, l_b, r_b, + neb, sub, naw, pro; + if ( u3_nul == a ) { + return u3k(b); + } + else if ( u3_nul == b ) { + return u3k(a); + } + else if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) + || (c3n == u3r_trel(b, &n_b, &l_b, &r_b)) ) + { + return u3m_bail(c3__exit); + } + else if ( c3n == u3qc_vor(n_a, n_b) ) { + if ( c3y == u3r_sing(n_a, n_b) ) { + return u3nt(u3k(n_b), _in_uni(l_a, l_b), _in_uni(r_a, r_b)); + } + else if ( c3y == u3qc_hor(n_a, n_b) ) { + naw = u3nt(u3k(n_a), u3k(l_a), u3_nul); + sub = _in_uni(naw, l_b); + neb = u3nt(u3k(n_b), sub, u3k(r_b)); + pro = _in_uni(r_a, neb); + u3z(naw); u3z(neb); + return pro; + } + else { + naw = u3nt(u3k(n_a), u3_nul, u3k(r_a)); + sub = _in_uni(naw, r_b); + neb = u3nt(u3k(n_b), u3k(l_b), sub); + pro = _in_uni(l_a, neb); + u3z(naw); u3z(neb); + return pro; + } + } + else if ( c3y == u3r_sing(n_b, n_a) ) { + return u3nt(u3k(n_b), _in_uni(l_a, l_b), _in_uni(r_a, r_b)); + } + else if ( c3y == u3qc_hor(n_b, n_a) ) { + neb = u3nt(u3k(n_b), u3k(l_b), u3_nul); + sub = _in_uni(l_a, neb); + naw = u3nt(u3k(n_a), sub, u3k(r_a)); + pro = _in_uni(naw, r_b); + u3z(neb); u3z(naw); + return pro; + } + else { + neb = u3nt(u3k(n_b), u3_nul, u3k(r_b)); + sub = _in_uni(r_a, neb); + naw = u3nt(u3k(n_a), u3k(l_a), sub); + pro = _in_uni(naw, l_b); + u3z(neb); u3z(naw); + return pro; + } +} + /* functions */ @@ -21,86 +83,11 @@ u3qdi_uni(u3_noun a, u3_noun b) { - if ( u3_nul == a ) { - return u3k(b); - } - else if ( u3_nul == b ) { + if ( c3y == u3r_sing(a, b) ) { return u3k(a); } else { - u3_noun l_a, n_a, r_a, lr_a; - u3_noun l_b, n_b, r_b, lr_b; - - if ( (c3n == u3r_cell(a, &n_a, &lr_a)) ) { - return u3m_bail(c3__exit); - } - else if ( (c3n == u3r_cell(b, &n_b, &lr_b)) ) { - return u3m_bail(c3__exit); - } - else { - if ( c3y == u3qc_vor(n_a, n_b) ) { - if ( c3n == u3r_cell(lr_a, &l_a, &r_a) ) { - return u3m_bail(c3__exit); - } - else if ( c3n == u3r_cell(lr_b, &l_b, &r_b) ) { - return u3m_bail(c3__exit); - } - else if ( c3y == u3r_sing(n_a, n_b) ) { - return u3nt(u3k(n_b), - u3kdi_uni(u3k(l_a), u3k(l_b)), - u3kdi_uni(u3k(r_a), u3k(r_b))); - } - else if ( c3y == u3qc_hor(n_b, n_a) ) { - return u3kdi_uni(u3nt(u3k(n_a), - u3kdi_uni(u3k(l_a), - u3nt(u3k(n_b), - u3k(l_b), - u3_nul)), - u3k(r_a)), - u3k(r_b)); - } - else { - return u3kdi_uni(u3nt(u3k(n_a), - u3k(l_a), - u3kdi_uni(u3k(r_a), - u3nt(u3k(n_b), - u3_nul, - u3k(r_b)))), - u3k(l_b)); - } - } - else { - if ( c3n == u3r_cell(lr_b, &l_b, &r_b) ) { - return u3m_bail(c3__exit); - } - else if ( c3n == u3r_cell(lr_a, &l_a, &r_a) ) { - return u3m_bail(c3__exit); - } - else if ( c3y == u3r_sing(n_b, n_a) ) { - return u3nt(u3k(n_b), - u3kdi_uni(u3k(l_a), u3k(l_b)), - u3kdi_uni(u3k(r_a), u3k(r_b))); - } - else if ( c3y == u3qc_hor(n_a, n_b) ) { - return u3kdi_uni(u3k(r_a), - u3nt(u3k(n_b), - u3kdi_uni(u3nt(u3k(n_a), - u3k(l_a), - u3_nul), - u3k(l_b)), - u3k(r_b))); - } - else { - return u3kdi_uni(u3k(l_a), - u3nt(u3k(n_b), - u3k(l_b), - u3kdi_uni(u3nt(u3k(n_a), - u3_nul, - u3k(r_a)), - u3k(r_b)))); - } - } - } + return _in_uni(a, b); } } u3_noun diff --git a/jets/d/in_wyt.c b/jets/d/in_wyt.c new file mode 100644 index 0000000000..ce7a11bbfd --- /dev/null +++ b/jets/d/in_wyt.c @@ -0,0 +1,30 @@ +/* jets/d/in_wyt.c +** +*/ +#include "all.h" + +/* functions +*/ + u3_noun u3wdi_wyt(u3_noun cor) + { + u3_noun a; + if ( c3n == u3r_mean(cor, u3x_con_2, &a, 0) ) { + return u3m_bail(c3__exit); + } else { + return u3qdi_wyt(a); + } + } + + u3_noun u3qdi_wyt(u3_noun a) + { + u3_noun n_a, l_a, r_a; + if ( u3_nul == a ) { + return 0; + } + else if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) { + return u3m_bail(c3__exit); + } + else { + return u3i_vint(u3ka_add(u3qdi_wyt(l_a), u3qdi_wyt(r_a))); + } + } diff --git a/jets/tree.c b/jets/tree.c index 1dff8ffebc..82d988e2d0 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -424,7 +424,8 @@ static u3j_core _149_tri_d[] = // static u3j_harm _149_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _149_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static u3j_harm _149_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; - // static u3j_harm _149_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; + static u3j_harm _149_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; + static u3j_harm _149_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static u3j_core _149_two__in_d[] = { { "bif", _149_two__in_bif_a }, { "dif", _149_two__in_dif_a }, @@ -434,7 +435,8 @@ static u3j_core _149_tri_d[] = // { "int", _149_two__in_int_a }, { "put", _149_two__in_put_a }, { "tap", _149_two__in_tap_a }, - // { "uni", _149_two__in_uni_a }, + { "wyt", _149_two__in_wyt_a }, + { "uni", _149_two__in_uni_a }, {} }; @@ -988,7 +990,8 @@ static u3j_core _150_tri_d[] = // static u3j_harm _150_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _150_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static u3j_harm _150_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; - // static u3j_harm _150_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; + static u3j_harm _150_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; + static u3j_harm _150_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static u3j_core _150_two__in_d[] = { { "bif", _150_two__in_bif_a }, { "dif", _150_two__in_dif_a }, @@ -998,7 +1001,8 @@ static u3j_core _150_tri_d[] = // { "int", _150_two__in_int_a }, { "put", _150_two__in_put_a }, { "tap", _150_two__in_tap_a }, - // { "uni", _150_two__in_uni_a }, + { "wyt", _150_two__in_wyt_a }, + { "uni", _150_two__in_uni_a }, {} };