shrub/jets/f/fork.c

119 lines
2.0 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/fork.c
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
/* functions
*/
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3qf_fork(u3_noun hoz,
u3_noun bur)
2013-09-29 00:21:18 +04:00
{
2014-11-06 03:20:01 +03:00
if ( c3y == u3r_sing(hoz, bur) ) {
2014-09-06 00:13:24 +04:00
return u3k(hoz);
2013-09-29 00:21:18 +04:00
}
else if ( c3__void == bur ) {
2014-09-06 00:13:24 +04:00
return u3k(hoz);
2013-09-29 00:21:18 +04:00
}
else if ( c3__void == hoz ) {
2014-09-06 00:13:24 +04:00
return u3k(bur);
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
else return u3nt
(c3__fork, u3k(hoz), u3k(bur));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3wf_fork(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun hoz, bur;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &hoz, u3x_sam_3, &bur, 0) ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-11-06 22:13:57 +03:00
return u3qf_fork(hoz, bur);
2013-09-29 00:21:18 +04:00
}
}
u3_noun
u3qf_forq(u3_noun hoz,
u3_noun bur)
{
if ( c3y == u3r_sing(hoz, bur) ) {
return u3k(hoz);
}
else if ( c3__void == bur ) {
return u3k(hoz);
}
else if ( c3__void == hoz ) {
return u3k(bur);
}
else return u3nq
(c3__frog, u3k(hoz), u3k(bur), u3_nul);
}
u3_noun
u3wf_forq(u3_noun cor)
{
u3_noun hoz, bur;
if ( c3n == u3r_mean(cor, u3x_sam_2, &hoz, u3x_sam_3, &bur, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qf_forq(hoz, bur);
}
}
u3_noun
u3qf_grof(u3_noun yed)
{
if ( u3_nul == yed ) {
return c3__void;
}
else if ( u3_nul == u3t(yed) ) {
return u3k(u3h(yed));
}
else {
u3_noun nex = u3qf_grof(u3t(yed));
u3_noun ret = u3qf_fork(u3h(yed), nex);
u3z(nex);
return ret;
}
}
u3_noun
u3qf_frog(u3_noun yed)
{
u3_noun lez = u3_nul;
while ( u3_nul != yed ) {
u3_noun i_yed = u3h(yed);
if ( c3__void != i_yed ) {
lez = u3kdi_put(lez, u3k(u3h(yed)));
}
yed = u3t(yed);
}
if ( u3_nul == lez ) {
return c3__void;
}
else if ( (u3_nul == u3h(u3t(lez))) && (u3_nul == u3t(u3t(lez))) ) {
u3_noun ret = u3k(u3h(lez));
u3z(lez);
return ret;
}
else {
return u3nc(c3__frog, u3kdi_tap(lez, u3_nul));
}
}
u3_noun
u3kf_frog(u3_noun yed)
{
u3_noun ret = u3qf_frog(yed);
u3z(yed);
return ret;
}