shrub/jets/d/in_int.c

77 lines
1.9 KiB
C
Raw Normal View History

/* j/4/in_int.c
2014-06-11 21:12:10 +04:00
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2014-06-11 21:12:10 +04:00
/* functions
*/
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 16:26:00 +03:00
u3qdi_int(u3_noun a,
u3_noun b)
2014-06-11 21:12:10 +04:00
{
2014-09-06 00:13:24 +04:00
if ( u3_nul == a ) {
return u3k(u3_nul);
2014-06-11 21:12:10 +04:00
}
2014-09-06 00:13:24 +04:00
else if ( u3_nul == b ) {
return u3k(u3_nul);
2014-06-11 21:12:10 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun l_a, n_a, r_a, lr_a;
u3_noun l_b, n_b, r_b, lr_b;
u3_noun c;
2014-06-11 21:12:10 +04:00
2014-11-06 03:20:01 +03:00
if ( (c3n == u3r_cell(a, &n_a, &lr_a)) ) {
return u3m_bail(c3__exit);
2014-06-11 21:12:10 +04:00
}
2014-11-06 03:20:01 +03:00
else if ( (c3n == u3r_cell(b, &n_b, &lr_b)) ) {
return u3m_bail(c3__exit);
2014-06-11 21:12:10 +04:00
}
else {
2014-11-06 22:13:57 +03:00
if ( c3y == u3qc_vor(n_b, n_a) ) {
2014-06-11 21:12:10 +04:00
c = a; a = b; b = c;
c = n_a; n_a = n_b; n_b = c;
c = lr_a; lr_a = lr_b; lr_b = c;
}
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_cell(lr_a, &l_a, &r_a) ) {
return u3m_bail(c3__exit);
2014-06-11 21:12:10 +04:00
}
2014-11-06 03:20:01 +03:00
else if ( c3n == u3r_cell(lr_b, &l_b, &r_b) ) {
return u3m_bail(c3__exit);
2014-06-11 21:12:10 +04:00
}
2014-11-06 03:20:01 +03:00
else if ( c3y == u3r_sing(n_a, n_b) ) {
2014-09-06 00:13:24 +04:00
return u3nt(u3k(n_a),
2015-08-28 16:26:00 +03:00
u3qdi_int(l_a, l_b),
u3qdi_int(r_a, r_b));
2014-06-11 21:12:10 +04:00
}
2014-11-06 22:13:57 +03:00
else if ( c3y == u3qc_hor(n_b, n_a) ) {
2015-08-28 16:26:00 +03:00
return u3qdi_uni(u3qdi_int(l_a,
u3nt(n_b,
l_b,
u3_nul)),
u3qdi_int(a,
r_b));
2014-06-11 21:12:10 +04:00
}
else {
2015-08-28 16:26:00 +03:00
return u3qdi_uni(u3qdi_int(r_a,
u3nt(n_b,
u3_nul,
r_b)),
u3qdi_int(a,
l_b));
2014-06-11 21:12:10 +04:00
}
}
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 16:26:00 +03:00
u3wdi_int(u3_noun cor)
2014-06-11 21:12:10 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-06-11 21:12:10 +04:00
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0) ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2014-06-11 21:12:10 +04:00
} else {
2014-11-06 22:13:57 +03:00
return u3qdi_int(a, b);
2014-06-11 21:12:10 +04:00
}
}