mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 01:41:37 +03:00
jet: +find
This commit is contained in:
parent
6ae065e652
commit
2cb18404f8
@ -20,6 +20,7 @@
|
||||
u3_noun u3wb_bind(u3_noun);
|
||||
u3_noun u3wb_clap(u3_noun);
|
||||
u3_noun u3wb_drop(u3_noun);
|
||||
u3_noun u3wb_find(u3_noun);
|
||||
u3_noun u3wb_flop(u3_noun);
|
||||
u3_noun u3wb_lent(u3_noun);
|
||||
u3_noun u3wb_levy(u3_noun);
|
||||
|
47
pkg/urbit/jets/b/find.c
Normal file
47
pkg/urbit/jets/b/find.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* j/2/find.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3qb_find(u3_noun nedl, u3_noun hstk)
|
||||
{
|
||||
c3_w i = 0;
|
||||
|
||||
while ( 1 ) {
|
||||
if ( u3_nul == nedl) {
|
||||
return u3_nul;
|
||||
} else if ( u3_nul == hstk ) {
|
||||
return u3_nul;
|
||||
}
|
||||
|
||||
u3_noun n = nedl;
|
||||
u3_noun h = hstk;
|
||||
while (c3y == u3r_sing(u3h(n), u3h(h))) {
|
||||
if ( u3_nul == u3t(n) ) {
|
||||
return u3nc(0, i);
|
||||
}
|
||||
|
||||
n = u3t(n);
|
||||
h = u3t(h);
|
||||
}
|
||||
|
||||
i = u3i_vint(i);
|
||||
hstk = u3t(hstk);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3wb_find(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) {
|
||||
return u3m_bail(c3__exit);
|
||||
} else {
|
||||
return u3qb_find(a, b);
|
||||
}
|
||||
}
|
@ -1286,6 +1286,8 @@ static c3_c* _141_tri_ha[] = {
|
||||
|
||||
/* layer two
|
||||
*/
|
||||
static u3j_harm _141_two_find_a[] = {{".2", u3wb_find, c3y}, {}};
|
||||
|
||||
static u3j_harm _141_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}};
|
||||
static c3_c* _141_two_flop_ha[] = {
|
||||
"73ac3be0119bcb822621de738f90975d98ce1ff3fb9a52853adc638271f61cd2",
|
||||
@ -1714,6 +1716,7 @@ static c3_c* _141_two_rub_ha[] = {
|
||||
static u3j_core _141_two_d[] =
|
||||
{ { "tri", 3, 0, _141_tri_d, _141_tri_ha },
|
||||
|
||||
{ "find", 7, _141_two_find_a },
|
||||
{ "flop", 7, _141_two_flop_a, 0, _141_two_flop_ha },
|
||||
{ "lent", 7, _141_two_lent_a, 0, _141_two_lent_ha },
|
||||
{ "levy", 7, _141_two_levy_a, 0, _141_two_levy_ha },
|
||||
|
Loading…
Reference in New Issue
Block a user