2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/ut_nest.c
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
/* logic
|
|
|
|
*/
|
|
|
|
/* forward
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2016-01-02 01:47:07 +03:00
|
|
|
_nest_sint(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2016-01-02 01:47:07 +03:00
|
|
|
_nest_dext(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2016-01-03 09:20:24 +03:00
|
|
|
_nest_clip(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
|
|
|
u3_noun dab,
|
|
|
|
u3_noun hem,
|
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
if ( u3_nul == dab ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3r_sing(u3_nul, hem);
|
2014-09-06 00:13:24 +04:00
|
|
|
} else if ( u3_nul == hem ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
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;
|
|
|
|
u3_noun n_hem, l_hem, r_hem;
|
|
|
|
u3_noun pn_hem, qn_hem, pn_dab, qn_dab;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3x_trel(dab, &n_dab, &l_dab, &r_dab);
|
|
|
|
u3x_trel(hem, &n_hem, &l_hem, &r_hem);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-03 09:20:24 +03:00
|
|
|
if ( (c3n == _nest_clip(van, sut, tel, ref, l_dab, l_hem, gil)) ||
|
|
|
|
(c3n == _nest_clip(van, sut, tel, ref, r_dab, r_hem, gil)) )
|
2016-01-02 01:47:07 +03:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-11-06 03:20:01 +03:00
|
|
|
u3x_cell(n_dab, &pn_dab, &qn_dab);
|
|
|
|
u3x_cell(n_hem, &pn_hem, &qn_hem);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_sing(pn_dab, pn_hem) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3n == u3du(qn_dab)) || (c3n == u3du(qn_hem)) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else switch ( u3h(qn_dab) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__exit);
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__ash: {
|
2014-09-06 00:13:24 +04:00
|
|
|
if ( c3__ash != u3h(qn_hem) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun pqn_dab = u3t(qn_dab);
|
|
|
|
u3_noun pqn_hem = u3t(qn_hem);
|
2014-11-06 22:13:57 +03:00
|
|
|
u3_noun vis = u3qfu_play(van, sut, pqn_dab);
|
|
|
|
u3_noun lon = u3qfu_play(van, ref, pqn_hem);
|
2015-12-25 00:14:59 +03:00
|
|
|
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun ret = _nest_dext(van, vis, tel, lon, u3_nul, u3_nul, gil);
|
2014-09-06 00:13:24 +04:00
|
|
|
|
|
|
|
u3z(vis);
|
|
|
|
u3z(lon);
|
2013-09-29 00:21:18 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__elm: {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3r_sing(qn_dab, qn_hem);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2014-09-07 00:39:13 +04:00
|
|
|
_nest_cong(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun p_sut, q_sut, p_ref, q_ref;
|
|
|
|
u3_noun pq_sut, qq_sut, rq_sut;
|
|
|
|
u3_noun pq_ref, qq_ref, rq_ref;
|
|
|
|
u3_noun prq_sut, qrq_sut, prq_ref, qrq_ref;
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun ret;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3x_trel(sut, 0, &p_sut, &q_sut);
|
|
|
|
u3x_trel(ref, 0, &p_ref, &q_ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut);
|
|
|
|
u3x_trel(q_ref, &pq_ref, &qq_ref, &rq_ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3x_cell(rq_sut, &prq_sut, &qrq_sut);
|
|
|
|
u3x_cell(rq_ref, &prq_ref, &qrq_ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3y == u3r_sing(q_sut, q_ref) ) {
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_dext(van, p_sut, tel, p_ref, u3_nul, u3_nul, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2016-01-02 01:47:07 +03:00
|
|
|
else if ( (c3n == _nest_dext
|
|
|
|
(van, qq_sut, tel, p_sut, u3_nul, u3_nul, gil)) ||
|
|
|
|
(c3n == _nest_dext
|
|
|
|
(van, p_sut, tel, qq_sut, u3_nul, u3_nul, gil)) ||
|
|
|
|
(c3n == _nest_dext
|
|
|
|
(van, qq_ref, tel, p_ref, u3_nul, u3_nul, gil)) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2016-01-03 09:20:24 +03:00
|
|
|
if ( (pq_sut != pq_ref) &&
|
|
|
|
(c3__lead != pq_sut) &&
|
|
|
|
(c3__gold != pq_ref) )
|
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun hud = u3nc(u3k(sut), u3k(ref));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
if ( (c3y == u3qdi_has(gil, hud)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(hud);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
else {
|
2014-11-06 22:13:57 +03:00
|
|
|
u3_noun zoc = u3qdi_put(gil, hud);
|
2015-12-24 11:20:22 +03:00
|
|
|
u3_noun tus = u3nt(c3__core,
|
|
|
|
u3k(qq_sut),
|
|
|
|
u3nc(c3__gold,
|
|
|
|
u3k(u3t(q_sut))));
|
2014-08-21 01:18:34 +04:00
|
|
|
|
2015-12-24 11:20:22 +03:00
|
|
|
u3_noun fer = u3nt(c3__core,
|
|
|
|
u3k(qq_ref),
|
|
|
|
u3nc(c3__gold,
|
|
|
|
u3k(u3t(q_ref))));
|
2015-12-25 00:14:59 +03:00
|
|
|
|
2016-01-03 09:20:24 +03:00
|
|
|
ret = _nest_clip(van, tus, tel, fer, qrq_sut, qrq_ref, zoc);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(fer);
|
|
|
|
u3z(tus);
|
|
|
|
u3z(zoc);
|
|
|
|
u3z(hud);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == ret ) {
|
|
|
|
return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch ( pq_sut ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
case c3__gold: {
|
2014-04-22 05:22:11 +04:00
|
|
|
return
|
2016-01-02 01:47:07 +03:00
|
|
|
c3a(_nest_dext(van, qq_sut, tel, qq_ref, u3_nul, u3_nul, gil),
|
|
|
|
_nest_dext(van, qq_ref, tel, qq_sut, u3_nul, u3_nul, gil));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
case c3__iron: {
|
2015-08-28 19:34:36 +03:00
|
|
|
u3_noun s_sam = u3qfu_peek(van, qq_sut, c3__rite, 2);
|
|
|
|
u3_noun r_sam = u3qfu_peek(van, qq_ref, c3__rite, 2);
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun ret = _nest_dext
|
|
|
|
(van, r_sam, tel, s_sam, u3_nul, u3_nul, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(r_sam);
|
|
|
|
u3z(s_sam);
|
2013-09-29 00:21:18 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
case c3__lead: {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
case c3__zinc: {
|
2015-08-28 19:34:36 +03:00
|
|
|
u3_noun s_pal = u3qfu_peek(van, qq_sut, c3__read, 2);
|
|
|
|
u3_noun r_pal = u3qfu_peek(van, qq_ref, c3__read, 2);
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun ret = _nest_dext
|
|
|
|
(van, s_pal, tel, r_pal, u3_nul, u3_nul, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(r_pal);
|
|
|
|
u3z(s_pal);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_nest_dext_in(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun seg,
|
|
|
|
u3_noun reg,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun p_sut, q_sut, p_ref, q_ref;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3n == u3du(sut)) ) switch ( sut ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
case c3__noun: {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
case c3__void: {
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else switch ( u3h(sut) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
case c3__atom: {
|
2015-12-28 06:18:25 +03:00
|
|
|
if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
|
|
|
}
|
|
|
|
else {
|
2015-12-28 11:45:12 +03:00
|
|
|
if ( c3y == u3r_pq(ref, c3__atom, &p_ref, &q_ref) ) {
|
2015-12-29 01:01:44 +03:00
|
|
|
if ( (c3n == u3qf_fitz(p_sut, p_ref)) ||
|
2015-12-28 06:18:25 +03:00
|
|
|
( (c3y == u3du(q_sut)) &&
|
2015-12-28 11:45:12 +03:00
|
|
|
( (c3n == u3du(q_ref)) ||
|
|
|
|
(c3n == u3r_sing(q_sut, q_ref)))) )
|
2015-12-28 06:18:25 +03:00
|
|
|
{
|
|
|
|
return c3n;
|
|
|
|
}
|
|
|
|
return c3y;
|
2015-12-27 23:17:04 +03:00
|
|
|
}
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
2015-12-27 23:17:04 +03:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
case c3__cell: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) {
|
2016-01-02 01:47:07 +03:00
|
|
|
return c3a(_nest_dext(van, p_sut, tel, p_ref, u3_nul, u3_nul, gil),
|
|
|
|
_nest_dext(van, q_sut, tel, q_ref, u3_nul, u3_nul, gil));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2016-01-02 01:47:07 +03:00
|
|
|
else return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__core: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3y == u3r_pq(ref, c3__core, &p_ref, &q_ref)) ) {
|
2014-08-21 01:18:34 +04:00
|
|
|
return _nest_cong(van, sut, tel, ref, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2016-01-02 01:47:07 +03:00
|
|
|
else return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__face: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
2014-04-22 05:22:11 +04:00
|
|
|
} else {
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_dext(van, q_sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2016-01-11 12:16:38 +03:00
|
|
|
case c3__fork: p_sut = u3t(sut);
|
|
|
|
{
|
|
|
|
u3_noun fop = u3qfu_repo(van, sut);
|
|
|
|
u3_noun ret = _nest_dext(van, fop, tel, ref, seg, reg, gil);
|
|
|
|
|
|
|
|
u3z(fop);
|
|
|
|
return ret;
|
|
|
|
}
|
2016-01-11 03:27:36 +03:00
|
|
|
case c3__frog: p_sut = u3t(sut);
|
|
|
|
{
|
|
|
|
if ( c3n == u3du(ref) ) switch ( ref ) {
|
|
|
|
default: return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
|
|
|
|
|
|
|
case c3__noun:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else switch ( u3h(ref) ) {
|
|
|
|
default: return _nest_sint(van, sut, tel, ref, seg, reg, gil);
|
|
|
|
|
|
|
|
case c3__atom:
|
|
|
|
case c3__cell:
|
|
|
|
case c3__core:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( u3_nul != p_sut ) {
|
|
|
|
if ( c3y == _nest_dext(van, u3h(p_sut), c3n, ref, seg, reg, gil) ) {
|
|
|
|
return c3y;
|
|
|
|
} else {
|
|
|
|
p_sut = u3t(p_sut);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c3n;
|
|
|
|
}
|
2016-01-11 09:37:59 +03:00
|
|
|
case c3__hold:
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2016-01-02 01:47:07 +03:00
|
|
|
if ( c3y == u3qdi_has(seg, sut) ) {
|
|
|
|
return c3n;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u3_noun hud = u3nc(u3k(sut), u3k(ref));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-02 01:47:07 +03:00
|
|
|
if ( (c3y == u3qdi_has(gil, hud)) ) {
|
|
|
|
u3z(hud);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-02 01:47:07 +03:00
|
|
|
return c3y;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u3_noun gus = u3qdi_put(seg, sut);
|
|
|
|
u3_noun zoc = u3qdi_put(gil, hud);
|
|
|
|
u3_noun fop = u3qfu_repo(van, sut);
|
|
|
|
u3_noun hiv = _nest_dext(van, fop, tel, ref, gus, reg, zoc);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-02 01:47:07 +03:00
|
|
|
u3z(hud);
|
|
|
|
u3z(fop);
|
|
|
|
u3z(zoc);
|
|
|
|
u3z(gus);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-02 01:47:07 +03:00
|
|
|
return hiv;
|
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_nest_dext_to(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun seg,
|
|
|
|
u3_noun reg,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun tyn = _nest_dext_in(van, sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3y == tyn) || (c3n == tel) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
return tyn;
|
|
|
|
} else {
|
2016-01-11 08:39:32 +03:00
|
|
|
#if 0
|
2016-01-07 04:47:03 +03:00
|
|
|
u3_noun dun = u3qfu_dunq(van, "need", sut);
|
|
|
|
u3_noun niz = u3qfu_dunq(van, "have", ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-07 04:47:03 +03:00
|
|
|
u3t_push(u3nc(c3__mean, dun));
|
|
|
|
u3t_push(u3nc(c3__mean, niz));
|
2016-01-07 10:08:09 +03:00
|
|
|
#endif
|
2016-01-02 01:47:07 +03:00
|
|
|
return u3m_error("nest-fail");
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_nest_dext(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun seg,
|
|
|
|
u3_noun reg,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-10-05 01:57:40 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3y == u3r_sing(sut, ref)) ) {
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-12-22 01:45:22 +03:00
|
|
|
c3_m fun_m = c3__nest + !!u3r_at(u3qfu_van_vet, van);
|
2014-11-06 03:20:01 +03:00
|
|
|
u3_noun pro = u3z_find_2(fun_m, sut, ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 02:36:30 +03:00
|
|
|
if ( u3_none != pro ) {
|
2014-09-03 09:46:55 +04:00
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
else {
|
2016-01-02 01:47:07 +03:00
|
|
|
pro = _nest_dext_to(van, sut, tel, ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3z_save_2(fun_m, sut, ref, pro);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
static u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_nest_sint(u3_noun van,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut,
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun tel,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun ref,
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun seg,
|
|
|
|
u3_noun reg,
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun gil)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun p_ref, q_ref;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( (c3n == u3du(ref)) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
switch ( ref ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
case c3__noun: return c3n;
|
|
|
|
case c3__void: return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-09-06 00:13:24 +04:00
|
|
|
switch ( u3h(ref) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
default: {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-11-05 04:18:47 +03:00
|
|
|
case c3__atom: return c3n;
|
|
|
|
case c3__cell: return c3n;
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__core: {
|
2014-11-06 22:13:57 +03:00
|
|
|
u3_noun gam = u3qfu_repo(van, ref);
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(gam);
|
2013-09-29 00:21:18 +04:00
|
|
|
return hiv;
|
|
|
|
}
|
|
|
|
case c3__face: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_dext(van, sut, tel, q_ref, seg, reg, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2016-01-11 12:16:38 +03:00
|
|
|
case c3__fork: p_ref = u3t(ref);
|
|
|
|
{
|
|
|
|
u3_noun gif = u3qfu_repo(van, ref);
|
|
|
|
u3_noun ret = _nest_sint(van, sut, tel, gif, seg, reg, gil);
|
|
|
|
|
|
|
|
u3z(gif);
|
|
|
|
return ret;
|
|
|
|
}
|
2016-01-11 03:27:36 +03:00
|
|
|
case c3__frog: {
|
|
|
|
p_ref = u3t(ref);
|
|
|
|
|
|
|
|
while ( u3_nul != p_ref ) {
|
|
|
|
if ( c3n == _nest_dext(van, sut, c3n, u3h(p_ref), seg, reg, gil) ) {
|
|
|
|
return c3n;
|
|
|
|
} else {
|
|
|
|
p_ref = u3t(p_ref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c3y;
|
|
|
|
}
|
2016-01-11 10:04:34 +03:00
|
|
|
case c3__hold: {
|
2016-01-02 01:47:07 +03:00
|
|
|
if ( c3y == u3qdi_has(reg, ref) ) {
|
|
|
|
return c3y;
|
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun hud = u3nc(u3k(sut), u3k(ref));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-06 22:13:57 +03:00
|
|
|
if ( (c3y == u3qdi_has(gil, hud)) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(hud);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
return c3y;
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun gur = u3qdi_put(reg, ref);
|
2014-11-06 22:13:57 +03:00
|
|
|
u3_noun zoc = u3qdi_put(gil, hud);
|
|
|
|
u3_noun gam = u3qfu_repo(van, ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
{
|
2016-01-02 01:47:07 +03:00
|
|
|
u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, gur, zoc);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(hud);
|
|
|
|
u3z(gam);
|
|
|
|
u3z(zoc);
|
2016-01-02 01:47:07 +03:00
|
|
|
u3z(gur);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return hiv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
_cqfu_nest(u3_noun van,
|
|
|
|
u3_noun sut,
|
|
|
|
u3_noun tel,
|
|
|
|
u3_noun ref)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2016-01-02 01:47:07 +03:00
|
|
|
return _nest_dext(van, sut, tel, ref, u3_nul, u3_nul, u3_nul);
|
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_nest(u3_noun cor)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut, tel, ref, van;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-18 00:56:51 +03:00
|
|
|
if ( (c3n == u3r_mean(cor, u3x_sam_2, &tel,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3x_sam_3, &ref,
|
|
|
|
u3x_con, &van,
|
|
|
|
0)) ||
|
2014-11-05 04:18:47 +03:00
|
|
|
(c3n == u3ud(tel)) || (tel > 1) ||
|
2014-11-18 00:56:51 +03:00
|
|
|
(u3_none == (sut = u3r_at(u3x_sam, van))) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-03 09:46:55 +04:00
|
|
|
return _cqfu_nest(van, sut, tel, ref);
|
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
|
|
|
u3qfu_nest(u3_noun van,
|
2015-08-28 19:34:36 +03:00
|
|
|
u3_noun sut,
|
|
|
|
u3_noun tel,
|
|
|
|
u3_noun ref)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-03 09:46:55 +04:00
|
|
|
return _cqfu_nest(van, sut, tel, ref);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|