mirror of
https://github.com/urbit/shrub.git
synced 2024-12-18 07:42:20 +03:00
79 lines
1.4 KiB
C
79 lines
1.4 KiB
C
/* j/4/by_get.c
|
|
**
|
|
** This file is in the public domain.
|
|
*/
|
|
#include "all.h"
|
|
|
|
|
|
/* functions
|
|
*/
|
|
u2_noun
|
|
u2_cqdb_get(
|
|
u2_noun a,
|
|
u2_noun b)
|
|
{
|
|
if ( u2_nul == a ) {
|
|
return u2_nul;
|
|
}
|
|
else {
|
|
u2_noun l_a, n_a, r_a;
|
|
u2_noun pn_a, qn_a;
|
|
|
|
if ( (u2_no == u2_cr_trel(a, &n_a, &l_a, &r_a)) ||
|
|
(u2_no == u2_cr_cell(n_a, &pn_a, &qn_a) ) )
|
|
{
|
|
return u2_cm_bail(c3__exit);
|
|
}
|
|
else {
|
|
if ( (u2_yes == u2_cr_sing(b, pn_a)) ) {
|
|
return u2nc(u2_nul, u2k(qn_a));
|
|
}
|
|
else {
|
|
if ( u2_yes == u2_cqc_gor(b, pn_a) ) {
|
|
return u2_cqdb_get(l_a, b);
|
|
}
|
|
else return u2_cqdb_get(r_a, b);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
u2_noun
|
|
u2_cwdb_get(
|
|
u2_noun cor)
|
|
{
|
|
u2_noun a, b;
|
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam, &b, u2_cv_con_sam, &a, 0) ) {
|
|
return u2_cm_bail(c3__exit);
|
|
} else {
|
|
return u2_cqdb_get(a, b);
|
|
}
|
|
}
|
|
u2_weak
|
|
u2_ckdb_get(u2_noun a, u2_noun b)
|
|
{
|
|
u2_noun c = u2_cqdb_get(a, b);
|
|
|
|
u2z(a); u2z(b);
|
|
if ( u2_no == u2_cr_du(c) ) {
|
|
u2z(c);
|
|
return u2_none;
|
|
} else {
|
|
u2_noun pro = u2k(u2t(c));
|
|
|
|
u2z(c);
|
|
return pro;
|
|
}
|
|
}
|
|
u2_noun
|
|
u2_ckdb_got(u2_noun a, u2_noun b)
|
|
{
|
|
u2_weak c = u2_ckdb_get(a, b);
|
|
|
|
if ( u2_none == c ) {
|
|
return u2_cm_bail(c3__exit);
|
|
}
|
|
else return c;
|
|
}
|
|
|