jet: +rep:in

This commit is contained in:
Elliot Glaysher 2020-05-12 10:40:33 -07:00
parent 94c66ec433
commit 1f7caacd15
3 changed files with 44 additions and 0 deletions

View File

@ -102,6 +102,7 @@
u3_noun u3wdi_has(u3_noun);
u3_noun u3wdi_int(u3_noun);
u3_noun u3wdi_put(u3_noun);
u3_noun u3wdi_rep(u3_noun);
u3_noun u3wdi_run(u3_noun);
u3_noun u3wdi_tap(u3_noun);
u3_noun u3wdi_uni(u3_noun);

41
pkg/urbit/jets/d/in_rep.c Normal file
View File

@ -0,0 +1,41 @@
/* j/4/in_rep.c
**
*/
#include "all.h"
/* internal functions
*/
static
void
_in_rep(u3_noun a, u3j_site* sit_u, u3_noun* out)
{
if (u3_nul == a) {
return;
} else {
u3_noun n_a, l_a, r_a;
u3x_trel(a, &n_a, &l_a, &r_a);
// consumes out refcount
*out = u3j_gate_slam(sit_u, u3nc(u3k(n_a), *out));
_in_rep(l_a, sit_u, out);
_in_rep(r_a, sit_u, out);
}
}
u3_noun
u3wdi_rep(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 out = u3k(u3x_at(u3x_sam_3, b));
_in_rep(a, &sit_u, &out);
u3j_gate_lose(&sit_u);
return out;
}

View File

@ -1574,6 +1574,7 @@ static c3_c* _141_two_xeb_ha[] = {
};
static u3j_harm _141_two__in_apt_a[] = {{".2", u3wdi_apt}, {}};
static u3j_harm _141_two__in_rep_a[] = {{".2", u3wdi_rep}, {}};
static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}};
static u3j_core _141_two__in_d[] =
@ -1585,6 +1586,7 @@ static u3j_core _141_two__in_d[] =
{ "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha },
// { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha },
{ "put", 7, _141_two__in_put_a, 0, _141_two__in_put_ha },
{ "rep", 7, _141_two__in_rep_a },
{ "run", 7, _141_two__in_run_a },
{ "tap", 7, _141_two__in_tap_a, 0, _141_two__in_tap_ha },
{ "wyt", 3, _141_two__in_wyt_a, 0, _141_two__in_wyt_ha },