urbit/j/4/in_tap.c
2014-09-05 13:13:24 -07:00

62 lines
1.1 KiB
C

/* j/4/in_tap.c
**
** This file is in the public domain.
*/
#include "all.h"
/* functions
*/
static u3_noun
_tap_in(
u3_noun a,
u3_noun b)
{
if ( u3_nul == a ) {
return b;
} else {
u3_noun l_a, n_a, r_a;
if ( (u3_no == u3_cr_trel(a, &n_a, &l_a, &r_a)) ) {
u3z(b);
return u3_cm_bail(c3__exit);
} else {
return _tap_in
(r_a,
u3nc(u3k(n_a),
_tap_in(l_a, b)));
}
}
}
u3_noun
u3_cqdi_tap(
u3_noun a,
u3_noun b)
{
return _tap_in(a, u3k(b));
}
u3_noun
u3_cwdi_tap(
u3_noun cor)
{
u3_noun a, b;
if ( u3_no == u3_cr_mean(cor, u3_cv_sam, &b, u3_cv_con_sam, &a, 0) ) {
return u3_cm_bail(c3__exit);
} else {
return u3_cqdi_tap(a, b);
}
}
u3_noun
u3_ckdi_tap(u3_noun a, u3_noun b)
{
u3_weak c = u3_cqdi_tap(a, b);
u3z(a); u3z(b);
if ( u3_none == c ) {
return u3_cm_bail(c3__exit);
}
else return c;
}