mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
jets: +key:by and +wyt:by
This commit is contained in:
parent
7149e591ef
commit
3f293cae47
@ -1603,6 +1603,7 @@
|
||||
d(l a(r l.d))
|
||||
::
|
||||
++ rep :: reduce to product
|
||||
~/ %rep
|
||||
|* b/_=>(~ |=({* *} +<+))
|
||||
|-
|
||||
?~ a +<+.b
|
||||
@ -1692,12 +1693,16 @@
|
||||
a(n n.a(q (b p.n.a q.n.a)), l $(a l.a), r $(a r.a))
|
||||
::
|
||||
++ wyt :: depth of map
|
||||
|- ^- @
|
||||
=< $
|
||||
~% %wyt + ~
|
||||
|. ^- @
|
||||
?~(a 0 +((add $(a l.a) $(a r.a))))
|
||||
::
|
||||
++ key :: set of keys
|
||||
=< $
|
||||
~/ %key
|
||||
=+ b=`(set _?>(?=(^ a) p.n.a))`~
|
||||
|- ^+ b
|
||||
|. ^+ b
|
||||
?~ a b
|
||||
$(a r.a, b $(a l.a, b (~(put in b) p.n.a)))
|
||||
::
|
||||
|
@ -86,10 +86,12 @@
|
||||
u3_noun u3wdb_has(u3_noun);
|
||||
u3_noun u3wdb_int(u3_noun);
|
||||
u3_noun u3wdb_jab(u3_noun);
|
||||
u3_noun u3wdb_key(u3_noun);
|
||||
u3_noun u3wdb_put(u3_noun);
|
||||
# define u3wdb_tap u3wdi_tap
|
||||
u3_noun u3wdb_uni(u3_noun);
|
||||
u3_noun u3wdb_run(u3_noun);
|
||||
# define u3wdb_wyt u3wdi_wyt
|
||||
|
||||
u3_noun u3wdi_bif(u3_noun);
|
||||
u3_noun u3wdi_del(u3_noun);
|
||||
|
35
pkg/urbit/jets/d/by_key.c
Normal file
35
pkg/urbit/jets/d/by_key.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* j/4/by_run.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
/* internal functions
|
||||
*/
|
||||
static u3_noun
|
||||
_by_key(u3_noun a, u3_noun set)
|
||||
{
|
||||
if (u3_nul == a) {
|
||||
return u3k(set);
|
||||
} 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 with_set = u3qdi_put(set, p_n_a);
|
||||
u3_noun left_set = _by_key(l_a, with_set);
|
||||
u3z(with_set);
|
||||
u3_noun right_set = _by_key(r_a, left_set);
|
||||
u3z(left_set);
|
||||
|
||||
return right_set;
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3wdb_key(u3_noun cor)
|
||||
{
|
||||
u3_noun a;
|
||||
u3x_mean(cor, u3x_con_sam, &a, 0);
|
||||
return _by_key(a, 0);
|
||||
}
|
@ -1636,7 +1636,9 @@ static c3_c* _141_two__in_ha[] = {
|
||||
0
|
||||
};
|
||||
|
||||
static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}};
|
||||
static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key}, {}};
|
||||
static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run}, {}};
|
||||
static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt}, {}};
|
||||
|
||||
static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}};
|
||||
static c3_c* _141_two__by_tap_ha[] = {
|
||||
@ -1657,9 +1659,11 @@ static u3j_core _141_two__by_d[] =
|
||||
{ "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha },
|
||||
// { "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 },
|
||||
{ "key", 7, _141_two__by_key_a },
|
||||
{ "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 },
|
||||
{ "wyt", 3, _141_two__by_wyt_a },
|
||||
// { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha },
|
||||
{}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user