2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/look.c
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/* internals
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
static u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_look_in(u3_noun cog,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun dab,
|
|
|
|
u3_atom axe)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
if ( u3_nul == dab ) {
|
|
|
|
return u3_nul;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun n_dab, l_dab, r_dab;
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3r_trel(dab, &n_dab, &l_dab, &r_dab);
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3du(n_dab) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pn_dab = u3h(n_dab);
|
|
|
|
u3_noun qn_dab = u3t(n_dab);
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
if ( (u3_nul == l_dab) && (u3_nul == r_dab) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3y == u3du(qn_dab)) &&
|
2014-11-06 03:20:01 +03:00
|
|
|
(c3y == u3r_sing(cog, pn_dab)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3nt(u3_nul,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3k(axe),
|
|
|
|
u3k(qn_dab));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3_nul;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else if ( (u3_nul == l_dab) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3y == u3du(qn_dab)) &&
|
2014-11-06 03:20:01 +03:00
|
|
|
(c3y == u3r_sing(cog, pn_dab)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3nt(u3_nul,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3qc_peg(axe, 2),
|
|
|
|
u3k(qn_dab));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-11-06 22:13:57 +03:00
|
|
|
if ( c3y == u3qc_gor(cog, pn_dab) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3_nul;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pro;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
axe = u3qc_peg(axe, 3);
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = _look_in(cog, r_dab, axe);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else if ( (u3_nul == r_dab) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3y == u3du(qn_dab)) &&
|
2014-11-06 03:20:01 +03:00
|
|
|
(c3y == u3r_sing(cog, pn_dab)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3nt(u3_nul,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3qc_peg(axe, 2),
|
|
|
|
u3k(qn_dab));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-11-06 22:13:57 +03:00
|
|
|
if ( c3y == u3qc_gor(cog, pn_dab) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pro;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
axe = u3qc_peg(axe, 3);
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = _look_in(cog, l_dab, axe);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3_nul;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3y == u3du(qn_dab)) &&
|
2014-11-06 03:20:01 +03:00
|
|
|
(c3y == u3r_sing(cog, pn_dab)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3nt(u3_nul,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3qc_peg(axe, 2),
|
|
|
|
u3k(qn_dab));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-11-06 22:13:57 +03:00
|
|
|
if ( c3y == u3qc_gor(cog, pn_dab) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pro;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
axe = u3qc_peg(axe, 6);
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = _look_in(cog, l_dab, axe);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pro;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
axe = u3qc_peg(axe, 7);
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = _look_in(cog, r_dab, axe);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* functions
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
u3qf_look(u3_noun cog,
|
|
|
|
u3_noun dab)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
return _look_in(cog, dab, 1);
|
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_look(u3_noun cor)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun cog, dab;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-18 00:56:51 +03:00
|
|
|
if ( c3n == u3r_mean(cor, u3x_sam_2, &cog, u3x_sam_3, &dab, 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_look(cog, dab);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|