Add jet for +del:in

This commit is contained in:
Elliot Glaysher 2018-12-13 14:39:53 -08:00
parent 16f346809a
commit e25c8388a4
4 changed files with 110 additions and 0 deletions

View File

@ -91,6 +91,7 @@
u3_noun u3wdb_uni(u3_noun);
u3_noun u3wdi_bif(u3_noun);
u3_noun u3wdi_del(u3_noun);
u3_noun u3wdi_dif(u3_noun);
u3_noun u3wdi_gas(u3_noun);
u3_noun u3wdi_has(u3_noun);

105
jets/d/in_del.c Normal file
View File

@ -0,0 +1,105 @@
/* j/4/in_del.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_rebalance(u3_noun a)
{
u3_noun l_a, n_a, r_a;
if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) {
return u3m_bail(c3__exit);
}
else {
if ( u3_nul == l_a) {
return u3k(r_a);
}
else if ( u3_nul == r_a) {
return u3k(l_a);
}
else {
u3_noun n_l_a, l_l_a, r_l_a;
u3_noun n_r_a, l_r_a, r_r_a;
if ( (c3n == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a) ) ||
(c3n == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a) ) ) {
return u3m_bail(c3__exit);
}
else {
if ( c3y == u3qc_vor(n_l_a, n_r_a) ) {
u3_noun new_right = u3nt(u3k(n_a),
u3k(r_l_a),
u3k(r_a));
u3_noun ret = u3nt(u3k(n_l_a),
u3k(l_l_a),
_rebalance(new_right));
u3z(new_right);
return ret;
}
else {
u3_noun new_left = u3nt(u3k(n_a),
u3k(l_a),
u3k(l_r_a));
u3_noun ret = u3nt(u3k(n_r_a),
_rebalance(new_left),
u3k(r_r_a));
u3z(new_left);
return ret;
}
}
}
}
}
u3_noun
u3qdi_del(u3_noun a,
u3_noun b)
{
if ( u3_nul == a ) {
return u3_nul;
}
else {
u3_noun l_a, n_a, r_a;
if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) ) {
return u3m_bail(c3__exit);
}
else if ( c3n == u3r_sing(n_a, b) ) {
if ( c3y == u3qc_hor(b, n_a) ) {
return u3nt(u3k(n_a),
u3qdi_del(l_a, b),
u3k(r_a));
}
else {
return u3nt(u3k(n_a),
u3k(l_a),
u3qdi_del(r_a, b));
}
}
else {
return _rebalance(a);
}
}
}
u3_noun
u3wdi_del(u3_noun cor)
{
u3_noun a, b;
if ( c3n == u3r_mean(cor, u3x_sam, &b,
u3x_con_sam, &a, 0) ) {
return u3m_bail(c3__exit);
}
else {
u3_noun n = u3qdi_del(a, b);
return n;
}
}

View File

@ -854,6 +854,8 @@ static c3_c* _141_two_xeb_ha[] = {0};
static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}};
static c3_c* _141_two__in_bif_ha[] = {0};
static u3j_harm _141_two__in_del_a[] = {{".2", u3wdi_del}, {}};
static c3_c* _141_two__in_del_ha[] = {0};
static u3j_harm _141_two__in_dif_a[] = {{".2", u3wdi_dif}, {}};
static c3_c* _141_two__in_dif_ha[] = {0};
static u3j_harm _141_two__in_gas_a[] = {{".2", u3wdi_gas}, {}};
@ -877,6 +879,7 @@ static c3_c* _141_two_xeb_ha[] = {0};
static c3_c* _141_two__in_uni_ha[] = {0};
static u3j_core _141_two__in_d[] =
{ { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha },
{ "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha },
{ "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha },
{ "gas", 7, _141_two__in_gas_a, 0, _141_two__in_gas_ha },
{ "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha },

View File

@ -90,6 +90,7 @@ jets_d_src = [
'jets/d/in_wyt.c',
'jets/d/in_bif.c',
'jets/d/in_dif.c',
'jets/d/in_del.c',
'jets/d/by_del.c',
'jets/d/by_gas.c',
'jets/d/by_get.c',