jets: +run:by

This commit is contained in:
Elliot Glaysher 2020-05-07 14:52:47 -07:00
parent c328e548d2
commit 7149e591ef
4 changed files with 44 additions and 0 deletions

View File

@ -1619,6 +1619,7 @@
[-.f a(l +.e, r +.f)]
::
++ run :: apply gate to values
~/ %run
|* b/gate
|-
?~ a a

View File

@ -89,6 +89,7 @@
u3_noun u3wdb_put(u3_noun);
# define u3wdb_tap u3wdi_tap
u3_noun u3wdb_uni(u3_noun);
u3_noun u3wdb_run(u3_noun);
u3_noun u3wdi_bif(u3_noun);
u3_noun u3wdi_del(u3_noun);

38
pkg/urbit/jets/d/by_run.c Normal file
View File

@ -0,0 +1,38 @@
/* j/4/by_run.c
**
*/
#include "all.h"
/* internal functions
*/
static u3_noun
_by_run(u3_noun a, u3j_site* sit_u)
{
if (u3_nul == a) {
return 0;
} else {
u3_noun n_a, l_a, r_a;
u3_noun p_n_a, q_n_a;
u3x_trel(a, &n_a, &l_a, &r_a);
u3x_cell(n_a, &p_n_a, &q_n_a);
u3_noun nu_q_n_a = u3j_gate_slam(sit_u, u3k(q_n_a));
u3_noun nu_l = _by_run(l_a, sit_u);
u3_noun nu_r = _by_run(r_a, sit_u);
return u3nt(u3nc(u3k(p_n_a), nu_q_n_a), nu_l, nu_r);
}
}
u3_noun
u3wdb_run(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_run(a, &sit_u);
u3j_gate_lose(&sit_u);
return pro;
}

View File

@ -1635,6 +1635,9 @@ static c3_c* _141_two__in_ha[] = {
"2cc9f005fde5314e9ad545286493a8c81b5c3b775d645ad82954f405d9414a32",
0
};
static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}};
static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}};
static c3_c* _141_two__by_tap_ha[] = {
"7dde59e2bd7684e785ce9787bc394571bd1216d7a62398c703447fc951c6b352",
@ -1655,6 +1658,7 @@ static u3j_core _141_two__by_d[] =
// { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha },
{ "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha },
{ "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha },
{ "run", 7, _141_two__by_run_a },
{ "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha },
// { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha },
{}