jets: +all:by and +any:by

This commit is contained in:
Elliot Glaysher 2020-05-12 14:04:25 -07:00
parent 3b645370e2
commit 6ae065e652
4 changed files with 101 additions and 1 deletions

View File

@ -78,6 +78,8 @@
/** Tier 4.
**/
u3_noun u3wdb_all(u3_noun);
u3_noun u3wdb_any(u3_noun);
u3_noun u3wdb_apt(u3_noun);
u3_noun u3wdb_bif(u3_noun);
u3_noun u3wdb_del(u3_noun);

47
pkg/urbit/jets/d/by_all.c Normal file
View File

@ -0,0 +1,47 @@
/* j/4/by_all.c
**
*/
#include "all.h"
/* internal functions
*/
static u3_noun
_by_all(u3_noun a, u3j_site* sit_u)
{
if (u3_nul == a) {
return c3y;
} else {
u3_noun n_a, l_a, r_a;
u3_noun q_n_a;
u3x_trel(a, &n_a, &l_a, &r_a);
u3x_cell(n_a, 0, &q_n_a);
if (c3n == u3j_gate_slam(sit_u, u3k(q_n_a))) {
return c3n;
}
if (c3n == _by_all(l_a, sit_u)) {
return c3n;
}
if (c3n == _by_all(r_a, sit_u)) {
return c3n;
}
return c3y;
}
}
u3_noun
u3wdb_all(u3_noun cor)
{
u3_noun a, b;
u3j_site sit_u;
u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0);
u3j_gate_prep(&sit_u, u3k(b));
u3_noun pro = _by_all(a, &sit_u);
u3j_gate_lose(&sit_u);
return pro;
}

47
pkg/urbit/jets/d/by_any.c Normal file
View File

@ -0,0 +1,47 @@
/* j/4/by_any.c
**
*/
#include "all.h"
/* internal functions
*/
static u3_noun
_by_any(u3_noun a, u3j_site* sit_u)
{
if (u3_nul == a) {
return c3n;
} else {
u3_noun n_a, l_a, r_a;
u3_noun q_n_a;
u3x_trel(a, &n_a, &l_a, &r_a);
u3x_cell(n_a, 0, &q_n_a);
if (c3y == u3j_gate_slam(sit_u, u3k(q_n_a))) {
return c3y;
}
if (c3y == _by_any(l_a, sit_u)) {
return c3y;
}
if (c3y == _by_any(r_a, sit_u)) {
return c3y;
}
return c3n;
}
}
u3_noun
u3wdb_any(u3_noun cor)
{
u3_noun a, b;
u3j_site sit_u;
u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0);
u3j_gate_prep(&sit_u, u3k(b));
u3_noun pro = _by_any(a, &sit_u);
u3j_gate_lose(&sit_u);
return pro;
}

View File

@ -1644,6 +1644,8 @@ static c3_c* _141_two__in_ha[] = {
0
};
static u3j_harm _141_two__by_all_a[] = {{".2", u3wdb_all, c3y}, {}};
static u3j_harm _141_two__by_any_a[] = {{".2", u3wdb_any, c3y}, {}};
static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}};
static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}};
static u3j_harm _141_two__by_rep_a[] = {{".2", u3wdb_rep, c3y}, {}};
@ -1662,7 +1664,9 @@ static c3_c* _141_two__in_ha[] = {
static c3_c* _141_two__by_uni_ha[] = {0};
static u3j_core _141_two__by_d[] =
{ { "apt", 7, _141_two__by_apt_a },
{ { "all", 7, _141_two__by_all_a },
{ "any", 7, _141_two__by_any_a },
{ "apt", 7, _141_two__by_apt_a },
{ "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha },
{ "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha },
{ "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha },