shrub/j/f/cons.c

56 lines
1.1 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/cons.c
**
** This file is in the public domain.
*/
#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
2014-11-06 22:13:57 +03:00
u3qf_cons(
2014-09-06 00:13:24 +04:00
u3_noun vur,
u3_noun sed)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun p_vur, p_sed;
2013-09-29 00:21:18 +04:00
2014-11-06 03:20:01 +03:00
if ( c3y == u3r_p(vur, 1, &p_vur) &&
c3y == u3r_p(sed, 1, &p_sed) ) {
2014-09-06 00:13:24 +04:00
return u3nt(1,
u3k(p_vur),
u3k(p_sed));
2013-09-29 00:21:18 +04:00
}
2014-11-06 03:20:01 +03:00
else if ( c3y == u3r_p(vur, 0, &p_vur) &&
c3y == u3r_p(sed, 0, &p_sed) &&
!(c3y == u3r_sing(1, p_vur)) &&
!(c3y == u3r_sing(p_vur, p_sed)) &&
(0 == u3r_nord(p_vur, p_sed)) )
2013-09-29 00:21:18 +04:00
{
2014-11-06 22:13:57 +03:00
u3_atom fub = u3qa_div(p_vur, 2);
u3_atom nof = u3qa_div(p_sed, 2);
2013-09-29 00:21:18 +04:00
2014-11-06 03:20:01 +03:00
if ( c3y == u3r_sing(fub, nof) ) {
2014-09-06 00:13:24 +04:00
u3z(nof);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
return u3nc(0, fub);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3z(fub);
u3z(nof);
2013-09-29 00:21:18 +04:00
}
}
2014-09-06 00:13:24 +04:00
return u3nc(u3k(vur), u3k(sed));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wf_cons(
2014-09-06 00:13:24 +04:00
u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun vur, sed;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &vur, u3x_sam_3, &sed, 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_cons(vur, sed);
2013-09-29 00:21:18 +04:00
}
}