urbit/jets/f/ut_swab.c

60 lines
1.1 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/swab.c
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
/* internals
*/
/* functions
*/
2014-09-06 00:13:24 +04:00
u3_noun
_cqfu_snub(u3_noun van,
u3_noun sut,
u3_noun har)
2013-12-15 12:23:23 +04:00
{
2014-11-05 04:18:47 +03:00
if ( c3n == u3du(har) ) {
2014-09-06 00:13:24 +04:00
return u3_nul;
2013-12-15 12:23:23 +04:00
} else {
2014-09-06 00:13:24 +04:00
u3_noun i_har = u3h(har);
u3_noun t_har = u3t(har);
u3_noun pi_har = u3h(i_har);
u3_noun qi_har = u3t(i_har);
2014-11-06 22:13:57 +03:00
u3_noun peh = u3qb_flop(pi_har);
2014-09-06 00:13:24 +04:00
u3_noun ret = u3nc(u3nc(peh, u3k(qi_har)),
2014-09-03 09:46:55 +04:00
_cqfu_snub
2014-08-21 01:18:34 +04:00
(van, sut, t_har));
2013-12-15 12:23:23 +04:00
return ret;
}
}
2013-09-29 00:21:18 +04:00
/* boilerplate
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wfu_snub(
2014-09-06 00:13:24 +04:00
u3_noun cor)
2013-12-15 12:23:23 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun van, sut, har;
2013-12-15 12:23:23 +04:00
2014-11-18 00:56:51 +03:00
if ( (c3n == u3r_mean(cor, u3x_sam, &har,
u3x_con, &van,
2013-12-15 12:23:23 +04:00
0)) ||
2014-11-18 00:56:51 +03:00
(u3_none == (sut = u3r_at(u3x_sam, van))) )
2013-12-15 12:23:23 +04:00
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-12-15 12:23:23 +04:00
} else {
2014-09-03 09:46:55 +04:00
return _cqfu_snub(van, sut, har);
2013-12-15 12:23:23 +04:00
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qfu_snub(u3_noun van,
2014-09-06 00:13:24 +04:00
u3_noun sut,
u3_noun har)
2013-12-15 12:23:23 +04:00
{
2014-09-03 09:46:55 +04:00
return _cqfu_snub(van, sut, har);
2013-12-15 12:23:23 +04:00
}