urbit/gen164/2/scag.c

52 lines
1.1 KiB
C
Raw Normal View History

2014-05-27 04:33:41 +04:00
/* j/2/scag.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* functions
*/
u2_weak // transfer
2014-08-20 01:49:16 +04:00
j2_mbc(Pt2, scag)(
2014-05-27 04:33:41 +04:00
u2_atom a, // retain
u2_noun b) // retain
{
2014-08-20 01:49:16 +04:00
if ( u2_ne(u2_co_is_cat(a)) ) {
return u2_cm_bail(c3__fail);
2014-05-27 04:33:41 +04:00
}
else {
u2_noun acc;
2014-05-27 04:33:41 +04:00
c3_w i_w = a;
if ( !i_w )
2014-05-27 04:33:41 +04:00
return u2_nul;
while ( i_w ) {
2014-08-20 01:49:16 +04:00
if ( u2_no == u2du(b) ) {
2014-05-27 04:33:41 +04:00
return u2_nul;
}
2014-08-20 01:49:16 +04:00
acc = u2_ci_cell( u2h(b), acc );
b = u2t(b);
2014-05-27 04:33:41 +04:00
i_w--;
}
return u2_ckb_flop(acc);
2014-05-27 04:33:41 +04:00
}
}
u2_noun // transfer
2014-08-20 01:49:16 +04:00
j2_mb(Pt2, scag)(
2014-05-27 04:33:41 +04:00
u2_noun cor) // retain
{
u2_noun a, b;
2014-08-20 01:49:16 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0)) ||
(u2_no == u2ud(a)) )
2014-05-27 04:33:41 +04:00
{
2014-08-20 01:49:16 +04:00
return u2_cm_bail(c3__exit);
2014-05-27 04:33:41 +04:00
} else {
2014-08-20 01:49:16 +04:00
return j2_mbc(Pt2, scag)(a, b);
2014-05-27 04:33:41 +04:00
}
}