diff --git a/pkg/noun/jets/c/aor.c b/pkg/noun/jets/c/aor.c new file mode 100644 index 0000000000..248661e777 --- /dev/null +++ b/pkg/noun/jets/c/aor.c @@ -0,0 +1,69 @@ +/// @file + +#include "jets/q.h" +#include "jets/w.h" + +#include "noun.h" + + u3_noun + u3qc_aor(u3_noun a, + u3_noun b) + { + while ( 1 ) { + if ( c3y == u3r_sing(a, b) ) return c3y; + if ( c3n == u3ud(a) ) { + if ( c3y == u3ud(b) ) return c3n; + if ( c3y == u3r_sing(u3h(a), u3h(b)) ) { + a = u3t(a); + b = u3t(b); + } + else { + a = u3h(a); + b = u3h(b); + } + } + else { + if ( c3n == u3ud(b) ) return c3y; + { + c3_w len_a_w = u3r_met(3, a); + c3_w len_b_w = u3r_met(3, b);; + c3_y *buf_a_y, *buf_b_y; + c3_y cut_a_y, cut_b_y; + if ( c3y == u3a_is_cat(a) ) { + buf_a_y = (c3_y*)&a; + } + else { + u3a_atom* a_u = u3a_to_ptr(a); + buf_a_y = (c3_y*)(a_u->buf_w); + } + if ( c3y == u3a_is_cat(b) ) { + buf_b_y = (c3_y*)&b; + } + else { + u3a_atom* b_u = u3a_to_ptr(b); + buf_b_y = (c3_y*)(b_u->buf_w); + } + c3_w len_min_w = c3_min(len_a_w, len_b_w); + for (c3_w i_w = 0; i_w < len_min_w; i_w++) { + cut_a_y = buf_a_y[i_w]; + cut_b_y = buf_b_y[i_w]; + if ( cut_a_y != cut_b_y ) return __(cut_a_y < cut_b_y); + } + return __(len_a_w < len_b_w); + } + } + } + } + + u3_noun + u3wc_aor(u3_noun cor) + { + u3_noun a, b; + + if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { + return u3m_bail(c3__exit); + } else { + return u3qc_aor(a, b); + } + } + diff --git a/pkg/noun/jets/q.h b/pkg/noun/jets/q.h index fd7c5981fb..b4fe7cd73e 100644 --- a/pkg/noun/jets/q.h +++ b/pkg/noun/jets/q.h @@ -48,6 +48,7 @@ /** Tier 3. **/ + u3_noun u3qc_aor(u3_atom, u3_atom); u3_noun u3qc_bex(u3_atom); u3_noun u3qc_xeb(u3_atom); u3_noun u3qc_can(u3_atom, u3_noun); diff --git a/pkg/noun/jets/tree.c b/pkg/noun/jets/tree.c index e40fe03846..bf06268b5b 100644 --- a/pkg/noun/jets/tree.c +++ b/pkg/noun/jets/tree.c @@ -2463,6 +2463,8 @@ static u3j_core _138_two__by_d[] = static u3j_harm _138_two_mate_a[] = {{".2", u3wb_mate, c3y}, {}}; +static u3j_harm _138_two_aor_a[] = {{".2", u3wc_aor, c3y}, {}}; + static u3j_core _138_two_d[] = { { "tri", 3, 0, _138_tri_d, no_hashes, _140_tri_ho }, @@ -2489,6 +2491,7 @@ static u3j_core _138_two_d[] = { "welp", 7, _140_two_welp_a, 0, no_hashes }, { "zing", 7, _140_two_zing_a, 0, no_hashes }, + { "aor", 7, _138_two_aor_a, 0, no_hashes }, { "bex", 7, _140_two_bex_a, 0, no_hashes }, { "cat", 7, _140_two_cat_a, 0, no_hashes }, { "can", 7, _140_two_can_a, 0, no_hashes }, diff --git a/pkg/noun/jets/w.h b/pkg/noun/jets/w.h index 34716971bd..275740cd97 100644 --- a/pkg/noun/jets/w.h +++ b/pkg/noun/jets/w.h @@ -50,6 +50,7 @@ /** Tier 3. **/ + u3_noun u3wc_aor(u3_noun); u3_noun u3wc_bex(u3_noun); u3_noun u3wc_xeb(u3_noun); u3_noun u3wc_can(u3_noun);