urbit/gen164/6/ut_find.c

777 lines
22 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/find.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* logic
*/
2013-12-31 23:30:37 +04:00
static u2_noun
2014-08-21 01:18:34 +04:00
_fino_in(
2013-12-31 23:30:37 +04:00
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog,
u2_noun gil)
{
u2_noun p_sut, q_sut;
2014-08-21 01:18:34 +04:00
if ( u2_yes == u2ud(sut) ) {
return u2nc(u2k(dep), u2_nul);
2013-12-31 23:30:37 +04:00
}
2014-08-21 01:18:34 +04:00
else switch ( u2h(sut) ) {
default: return u2nc(u2k(dep), u2_nul);
2013-12-31 23:30:37 +04:00
case c3__bull: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
}
else {
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(cog, u2h(p_sut)) ) {
2014-01-02 00:47:18 +04:00
return _fino_in
2014-08-21 01:18:34 +04:00
(van, q_sut, dep, way, cog, gil);
}
2013-12-31 23:30:37 +04:00
else {
if ( 0 == dep ) {
2014-08-21 01:18:34 +04:00
return u2nc
(0,
u2nt(
u2_nul,
2013-12-31 23:30:37 +04:00
1,
2014-08-21 01:18:34 +04:00
u2nt(2, u2k(p_sut),
u2k(q_sut))));
2013-12-31 23:30:37 +04:00
} else {
2014-01-02 00:47:18 +04:00
return _fino_in
2014-08-21 01:18:34 +04:00
(
2014-09-03 07:36:29 +04:00
van, q_sut, u2_cqa_dec(dep), way, cog, gil);
2013-12-31 23:30:37 +04:00
}
}
}
}
case c3__cell: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
2013-12-31 23:30:37 +04:00
} else {
2014-08-21 01:18:34 +04:00
u2_noun taf = _fino_in(van, p_sut, dep, way, cog, gil);
u2_noun p_taf = u2h(taf);
u2_noun q_taf = u2t(taf);
2013-12-31 23:30:37 +04:00
u2_noun ret;
if ( u2_nul == q_taf ) {
2014-08-21 01:18:34 +04:00
u2_noun bov = _fino_in(van, q_sut, p_taf, way, cog, gil);
u2_noun p_bov = u2h(bov);
u2_noun q_bov = u2t(bov);
2013-12-31 23:30:37 +04:00
if ( u2_nul == q_bov ) {
2014-08-21 01:18:34 +04:00
ret = u2k(bov);
}
2013-12-31 23:30:37 +04:00
else {
u2_noun puq_bov, quq_bov;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_bov, 6, &puq_bov, 7, &quq_bov, 0);
ret = u2nq
(u2k(p_bov),
2013-12-31 23:30:37 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(3, puq_bov),
2014-08-21 01:18:34 +04:00
u2k(quq_bov));
2013-12-31 23:30:37 +04:00
}
2014-08-21 01:18:34 +04:00
u2z(bov);
}
2013-12-31 23:30:37 +04:00
else {
u2_noun puq_taf, quq_taf;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_taf, 6, &puq_taf, 7, &quq_taf, 0);
ret = u2nq
(u2k(p_taf),
2013-12-31 23:30:37 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(2, puq_taf),
2014-08-21 01:18:34 +04:00
u2k(quq_taf));
2013-12-31 23:30:37 +04:00
}
2014-08-21 01:18:34 +04:00
u2z(taf);
2013-12-31 23:30:37 +04:00
return ret;
}
}
case c3__core: {
u2_noun pq_sut, qq_sut, rq_sut;
u2_noun prq_sut, qrq_sut;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ||
(u2_no == u2_cr_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
(u2_no == u2_cr_cell(rq_sut, &prq_sut, &qrq_sut)) )
2013-12-31 23:30:37 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-12-31 23:30:37 +04:00
} else {
2014-09-03 07:36:29 +04:00
u2_noun zem = u2_cqf_look(cog, qrq_sut);
2013-12-31 23:30:37 +04:00
if ( (u2_nul != zem) && (0 != dep) ) {
u2_noun ped;
2014-09-03 07:36:29 +04:00
ped = u2_cqa_dec(dep);
2014-08-21 01:18:34 +04:00
u2z(dep); dep = ped;
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2z(zem);
2013-12-31 23:30:37 +04:00
zem = u2_nul;
}
if ( u2_nul == zem ) {
2014-08-21 01:18:34 +04:00
u2_noun taf = _fino_in(van, p_sut, dep, way, cog, gil);
u2_noun p_taf = u2h(taf);
u2_noun q_taf = u2t(taf);
2013-12-31 23:30:37 +04:00
if ( u2_nul == q_taf ) {
2014-08-21 01:18:34 +04:00
u2z(taf);
return u2nc(u2k(dep), u2_nul);
}
2013-12-31 23:30:37 +04:00
else {
u2_noun puq_taf, quq_taf;
u2_noun pro;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_taf, 6, &puq_taf, 7, &quq_taf, 0);
2013-12-31 23:30:37 +04:00
2014-09-03 07:36:29 +04:00
if ( u2_no == u2_cqfu_park
2014-08-21 01:18:34 +04:00
(van, sut, way, puq_taf) )
2013-12-31 23:30:37 +04:00
{
2014-09-03 07:36:29 +04:00
u2_noun weh = u2_cqfu_shep
2014-08-21 01:18:34 +04:00
(van, "way", 'a', u2k(way));
2014-09-03 07:36:29 +04:00
u2_noun waz = u2_cqfu_shep
2014-08-21 01:18:34 +04:00
(van, "axis", 'd', u2k(puq_taf));
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2_ct_push(u2nc(c3__mean, weh));
u2_ct_push(u2nc(c3__mean, waz));
return u2_cm_error("find-park");
2013-12-31 23:30:37 +04:00
}
else {
2014-08-21 01:18:34 +04:00
pro = u2nq
(u2k(p_taf),
2013-12-31 23:30:37 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(3, puq_taf),
2014-08-21 01:18:34 +04:00
u2k(quq_taf));
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2z(taf);
2013-12-31 23:30:37 +04:00
return pro;
}
}
}
else {
2014-08-21 01:18:34 +04:00
u2_noun u_zem = u2t(zem);
u2_noun pu_zem = u2h(u_zem);
u2_noun qu_zem = u2t(u_zem);
2013-12-31 23:30:37 +04:00
u2_noun mut;
u2_noun pro;
2014-08-21 01:18:34 +04:00
mut = u2nt(c3__core,
u2k(p_sut),
u2nt(c3__gold,
u2k(qq_sut),
u2k(rq_sut)));
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
pro = u2nc
(
2013-12-31 23:30:37 +04:00
0,
2014-08-21 01:18:34 +04:00
u2nq(
2013-12-31 23:30:37 +04:00
u2_nul,
2014-08-21 01:18:34 +04:00
1,
1,
u2nc
2014-09-03 07:36:29 +04:00
(u2_cqc_peg(2, pu_zem),
2014-08-21 01:18:34 +04:00
u2nc(
u2nc(mut, u2k(qu_zem)),
2013-12-31 23:30:37 +04:00
u2_nul))));
2014-08-21 01:18:34 +04:00
u2z(zem);
2013-12-31 23:30:37 +04:00
return pro;
}
}
}
case c3__face: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
} else {
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(cog, p_sut) ) {
return u2nc(u2k(dep), u2_nul);
2013-12-31 23:30:37 +04:00
} else {
if ( 0 == dep ) {
2014-08-21 01:18:34 +04:00
return u2nc
(0,
u2nq(u2_nul, 1, 0, u2k(q_sut)));
2013-12-31 23:30:37 +04:00
} else {
2014-08-21 01:18:34 +04:00
return u2nc
2014-09-03 07:36:29 +04:00
(u2_cqa_dec(dep), u2_nul);
2013-12-31 23:30:37 +04:00
}
}
}
}
case c3__cube: {
2014-09-03 07:36:29 +04:00
u2_noun fop = u2_cqfu_repo(van, sut);
2014-08-21 01:18:34 +04:00
u2_noun pro = _fino_in(van, fop, dep, way, cog, gil);
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2z(fop);
2013-12-31 23:30:37 +04:00
return pro;
}
case c3__fork: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
2013-12-31 23:30:37 +04:00
}
2014-09-03 07:36:29 +04:00
if ( (u2_yes == u2_cqdi_has(gil, q_sut)) ) {
2014-08-21 01:18:34 +04:00
return _fino_in(van, p_sut, dep, way, cog, gil);
}
2014-09-03 07:36:29 +04:00
else if ( (u2_yes == u2_cqdi_has(gil, p_sut)) ) {
2014-08-21 01:18:34 +04:00
return _fino_in(van, q_sut, dep, way, cog, gil);
}
2013-12-31 23:30:37 +04:00
else {
2014-08-21 01:18:34 +04:00
u2_noun hax = _fino_in(van, p_sut, dep, way, cog, gil);
u2_noun yor = _fino_in(van, q_sut, dep, way, cog, gil);
u2_noun p_hax = u2h(hax);
u2_noun p_yor = u2h(yor);
u2_noun q_hax = u2t(hax);
u2_noun q_yor = u2t(yor);
2013-12-31 23:30:37 +04:00
u2_noun puq_hax, quq_hax;
u2_noun puq_yor, quq_yor;
u2_noun ret;
if ( u2_nul != q_hax ) {
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_hax, 6, &puq_hax, 7, &quq_hax, 0);
2013-12-31 23:30:37 +04:00
}
if ( u2_nul != q_yor ) {
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_yor, 6, &puq_yor, 7, &quq_yor, 0);
2013-12-31 23:30:37 +04:00
}
2014-08-21 01:18:34 +04:00
if ( u2_yes == u2_cr_sing(hax, yor) ) {
ret = u2k(hax);
2013-12-31 23:30:37 +04:00
}
else {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_sing(p_hax, p_yor)) ||
2013-12-31 23:30:37 +04:00
((u2_nul == q_hax) || (u2_nul == q_yor)) ||
2014-08-21 01:18:34 +04:00
(u2_no == u2_cr_sing(puq_hax, puq_yor)) ||
(u2_no == u2_cr_sing(u2h(quq_hax), u2h(quq_yor))) )
2013-12-31 23:30:37 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_error("find-fork");
2013-12-31 23:30:37 +04:00
}
2014-08-21 01:18:34 +04:00
switch ( u2h(quq_hax) ) {
2013-12-31 23:30:37 +04:00
case 0: {
2014-08-21 01:18:34 +04:00
u2_noun pquq_hax = u2t(quq_hax);
u2_noun pquq_yor = u2t(quq_yor);
ret = u2nc
(
u2k(p_hax),
u2nq
(
2013-12-31 23:30:37 +04:00
u2_nul,
2014-08-21 01:18:34 +04:00
u2k(puq_hax),
2013-12-31 23:30:37 +04:00
0,
2014-09-03 07:36:29 +04:00
u2_cqf_fork(pquq_hax, pquq_yor)));
2013-12-31 23:30:37 +04:00
break;
}
case 1: {
u2_noun pquq_hax, qquq_hax, pquq_yor, qquq_yor;
2014-08-21 01:18:34 +04:00
u2_cx_cell(u2t(quq_hax), &pquq_hax, &qquq_hax);
u2_cx_cell(u2t(quq_yor), &pquq_yor, &qquq_yor);
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(pquq_hax, pquq_yor) ) {
return u2_cm_error("find-fork");
2013-12-31 23:30:37 +04:00
} else {
2014-08-21 01:18:34 +04:00
ret = u2nc
(
u2k(p_hax),
u2nq
(u2_nul,
u2k(puq_hax),
2013-12-31 23:30:37 +04:00
1,
2014-08-21 01:18:34 +04:00
u2nc
(u2k(pquq_hax),
2014-09-03 07:36:29 +04:00
u2_cqb_weld
2014-08-21 01:18:34 +04:00
(qquq_hax, qquq_yor))));
2013-12-31 23:30:37 +04:00
break;
}
}
case 2: {
u2_noun pquq_hax, qquq_hax, pquq_yor, qquq_yor;
2014-01-02 00:47:18 +04:00
u2_noun ppquq_hax, qpquq_hax, rpquq_hax, spquq_hax;
u2_noun ppquq_yor, qpquq_yor, rpquq_yor, spquq_yor;
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2_cx_cell(u2t(quq_hax), &pquq_hax, &qquq_hax);
u2_cx_cell(u2t(quq_yor), &pquq_yor, &qquq_yor);
u2_cx_qual(
pquq_hax,
2014-01-02 00:47:18 +04:00
&ppquq_hax, &qpquq_hax, &rpquq_hax, &spquq_hax);
2014-08-21 01:18:34 +04:00
u2_cx_qual(
pquq_yor,
2014-01-02 00:47:18 +04:00
&ppquq_yor, &qpquq_yor, &rpquq_yor, &spquq_yor);
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_sing(ppquq_hax, ppquq_yor)) ||
(u2_no == u2_cr_sing(qpquq_hax, qpquq_yor)) ||
(u2_no == u2_cr_sing(rpquq_hax, rpquq_yor)) )
2014-01-02 00:47:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_error("find-fork");
2013-12-31 23:30:37 +04:00
}
else {
2014-08-21 01:18:34 +04:00
ret = u2nc
(
u2k(p_hax),
u2nq
(
2013-12-31 23:30:37 +04:00
u2_nul,
2014-08-21 01:18:34 +04:00
u2k(puq_hax),
2013-12-31 23:30:37 +04:00
2,
2014-08-21 01:18:34 +04:00
u2nc(
u2nq(
u2k(ppquq_hax),
u2k(qpquq_hax),
u2k(rpquq_hax),
2014-09-03 07:36:29 +04:00
u2_cqf_fork(
spquq_hax,
2014-01-02 00:47:18 +04:00
spquq_yor)),
2014-09-03 07:36:29 +04:00
u2_cqf_fork(qquq_hax, qquq_yor))));
2013-12-31 23:30:37 +04:00
break;
}
}
}
}
2014-08-21 01:18:34 +04:00
u2z(yor);
u2z(hax);
2013-12-31 23:30:37 +04:00
return ret;
}
}
2014-08-21 01:18:34 +04:00
case c3__hold: p_sut = u2t(sut);
2013-12-31 23:30:37 +04:00
{
2014-09-03 07:36:29 +04:00
if ( (u2_yes == u2_cqdi_has(gil, sut)) ) {
2014-08-21 01:18:34 +04:00
return u2nc(u2k(dep), u2_nul);
}
2013-12-31 23:30:37 +04:00
else {
2014-09-03 07:36:29 +04:00
u2_noun zoc = u2_cqdi_put(gil, sut);
u2_noun fop = u2_cqfu_repo(van, sut);
2014-08-21 01:18:34 +04:00
u2_noun pro = _fino_in(van, fop, dep, way, cog, zoc);
2013-12-31 23:30:37 +04:00
2014-08-21 01:18:34 +04:00
u2z(fop);
u2z(zoc);
2013-12-31 23:30:37 +04:00
return pro;
}
}
}
}
2013-09-29 00:21:18 +04:00
static u2_noun
2014-08-21 01:18:34 +04:00
_find_in(
2013-09-29 00:21:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog,
u2_noun gil)
{
2014-01-05 00:19:59 +04:00
u2_noun p_sut, q_sut, pp_sut, qp_sut, rp_sut, sp_sut;
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
if ( u2_yes == u2ud(sut) ) {
return u2nc(u2k(dep), u2_nul);
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
else switch ( u2h(sut) ) {
default: return u2nc(u2k(dep), u2_nul);
2013-09-29 00:21:18 +04:00
2013-12-26 21:12:07 +04:00
case c3__bull: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ||
(u2_no == u2_cr_qual(p_sut, &pp_sut, &qp_sut, &rp_sut, &sp_sut)) )
2013-12-26 21:12:07 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
}
else {
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(cog, pp_sut) ) {
2014-01-02 00:47:18 +04:00
return _find_in
2014-08-21 01:18:34 +04:00
(van, q_sut, dep, way, cog, gil);
}
2013-12-26 21:12:07 +04:00
else {
if ( 0 == dep ) {
2014-08-21 01:18:34 +04:00
return u2nc
(0,
u2nq(
u2_nul,
2014-08-21 01:18:34 +04:00
u2k(rp_sut),
u2_yes,
2014-08-21 01:18:34 +04:00
u2k(sp_sut)));
2013-12-26 21:12:07 +04:00
} else {
2014-01-02 00:47:18 +04:00
return _find_in
2014-08-21 01:18:34 +04:00
(
2014-09-03 07:36:29 +04:00
van, q_sut, u2_cqa_dec(dep), way, cog, gil);
2014-08-21 01:18:34 +04:00
return u2nc
2014-09-03 07:36:29 +04:00
(u2_cqa_dec(dep), u2_nul);
2013-12-26 21:12:07 +04:00
}
}
}
}
2013-09-29 00:21:18 +04:00
case c3__cell: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-08-21 01:18:34 +04:00
u2_noun taf = _find_in(van, p_sut, dep, way, cog, gil);
u2_noun p_taf = u2h(taf);
u2_noun q_taf = u2t(taf);
2013-09-29 00:21:18 +04:00
u2_noun ret;
if ( u2_nul == q_taf ) {
2014-08-21 01:18:34 +04:00
u2_noun bov = _find_in(van, q_sut, p_taf, way, cog, gil);
u2_noun p_bov = u2h(bov);
u2_noun q_bov = u2t(bov);
2013-09-29 00:21:18 +04:00
if ( u2_nul == q_bov ) {
2014-08-21 01:18:34 +04:00
ret = u2k(bov);
}
2013-09-29 00:21:18 +04:00
else {
u2_noun puq_bov, quq_bov;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_bov, 6, &puq_bov, 7, &quq_bov, 0);
ret = u2nq
(u2k(p_bov),
2013-09-29 00:21:18 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(3, puq_bov),
2014-08-21 01:18:34 +04:00
u2k(quq_bov));
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
u2z(bov);
}
2013-09-29 00:21:18 +04:00
else {
u2_noun puq_taf, quq_taf;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_taf, 6, &puq_taf, 7, &quq_taf, 0);
ret = u2nq
(u2k(p_taf),
2013-09-29 00:21:18 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(2, puq_taf),
2014-08-21 01:18:34 +04:00
u2k(quq_taf));
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
u2z(taf);
2013-09-29 00:21:18 +04:00
return ret;
}
}
case c3__core: {
u2_noun pq_sut, qq_sut, rq_sut;
u2_noun prq_sut, qrq_sut;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ||
(u2_no == u2_cr_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
(u2_no == u2_cr_cell(rq_sut, &prq_sut, &qrq_sut)) )
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 07:36:29 +04:00
u2_noun zem = u2_cqf_look(cog, qrq_sut);
2013-09-29 00:21:18 +04:00
if ( (u2_nul != zem) && (0 != dep) ) {
u2_noun ped;
2014-09-03 07:36:29 +04:00
ped = u2_cqa_dec(dep);
2014-08-21 01:18:34 +04:00
u2z(dep); dep = ped;
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(zem);
2013-09-29 00:21:18 +04:00
zem = u2_nul;
}
if ( u2_nul == zem ) {
2014-08-21 01:18:34 +04:00
u2_noun taf = _find_in(van, p_sut, dep, way, cog, gil);
u2_noun p_taf = u2h(taf);
u2_noun q_taf = u2t(taf);
2013-09-29 00:21:18 +04:00
if ( u2_nul == q_taf ) {
2014-08-21 01:18:34 +04:00
u2z(taf);
return u2nc(u2k(dep), u2_nul);
}
2013-09-29 00:21:18 +04:00
else {
u2_noun puq_taf, quq_taf;
u2_noun pro;
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_taf, 6, &puq_taf, 7, &quq_taf, 0);
2013-09-29 00:21:18 +04:00
2014-09-03 07:36:29 +04:00
if ( u2_no == u2_cqfu_park
2014-08-21 01:18:34 +04:00
(van, sut, way, puq_taf) )
2013-09-29 00:21:18 +04:00
{
2014-09-03 07:36:29 +04:00
u2_noun weh = u2_cqfu_shep
2014-08-21 01:18:34 +04:00
(van, "way", 'a', u2k(way));
2014-09-03 07:36:29 +04:00
u2_noun waz = u2_cqfu_shep
2014-08-21 01:18:34 +04:00
(van, "axis", 'd', u2k(puq_taf));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2_ct_push(u2nc(c3__mean, weh));
u2_ct_push(u2nc(c3__mean, waz));
return u2_cm_error("find-park");
2013-09-29 00:21:18 +04:00
}
else {
2014-08-21 01:18:34 +04:00
pro = u2nq
(u2k(p_taf),
2013-09-29 00:21:18 +04:00
u2_nul,
2014-09-03 07:36:29 +04:00
u2_cqc_peg(3, puq_taf),
2014-08-21 01:18:34 +04:00
u2k(quq_taf));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(taf);
2013-09-29 00:21:18 +04:00
return pro;
}
}
}
else {
2014-08-21 01:18:34 +04:00
u2_noun u_zem = u2t(zem);
u2_noun pu_zem = u2h(u_zem);
u2_noun qu_zem = u2t(u_zem);
2013-09-29 00:21:18 +04:00
u2_noun mut;
u2_noun pro;
2014-08-21 01:18:34 +04:00
mut = u2nt(c3__core,
u2k(p_sut),
u2nt(c3__gold,
u2k(qq_sut),
u2k(rq_sut)));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
pro = u2nc
(
2013-09-29 00:21:18 +04:00
0,
2014-08-21 01:18:34 +04:00
u2nq(
2013-09-29 00:21:18 +04:00
u2_nul,
2014-08-21 01:18:34 +04:00
1,
2013-09-29 00:21:18 +04:00
u2_no,
2014-08-21 01:18:34 +04:00
u2nc
2014-09-03 07:36:29 +04:00
(u2_cqc_peg(2, pu_zem),
2014-08-21 01:18:34 +04:00
u2nc(
u2nc(mut, u2k(qu_zem)),
2013-09-29 00:21:18 +04:00
u2_nul))));
2014-08-21 01:18:34 +04:00
u2z(zem);
2013-09-29 00:21:18 +04:00
return pro;
}
}
}
case c3__face: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
} else {
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(cog, p_sut) ) {
return u2nc(u2k(dep), u2_nul);
2013-09-29 00:21:18 +04:00
} else {
if ( 0 == dep ) {
2014-08-21 01:18:34 +04:00
return u2nc
(0,
u2nq(u2_nul, 1, u2_yes, u2k(q_sut)));
2013-09-29 00:21:18 +04:00
} else {
2014-08-21 01:18:34 +04:00
return u2nc
2014-09-03 07:36:29 +04:00
(u2_cqa_dec(dep), u2_nul);
2013-09-29 00:21:18 +04:00
}
}
}
}
case c3__cube: {
2014-09-03 07:36:29 +04:00
u2_noun fop = u2_cqfu_repo(van, sut);
2014-08-21 01:18:34 +04:00
u2_noun pro = _find_in(van, fop, dep, way, cog, gil);
2014-08-21 01:18:34 +04:00
u2z(fop);
return pro;
}
2013-09-29 00:21:18 +04:00
case c3__fork: {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
}
2014-09-03 07:36:29 +04:00
if ( (u2_yes == u2_cqdi_has(gil, q_sut)) ) {
2014-08-21 01:18:34 +04:00
return _find_in(van, p_sut, dep, way, cog, gil);
}
2014-09-03 07:36:29 +04:00
else if ( (u2_yes == u2_cqdi_has(gil, p_sut)) ) {
2014-08-21 01:18:34 +04:00
return _find_in(van, q_sut, dep, way, cog, gil);
}
2013-09-29 00:21:18 +04:00
else {
2014-08-21 01:18:34 +04:00
u2_noun hax = _find_in(van, p_sut, dep, way, cog, gil);
u2_noun yor = _find_in(van, q_sut, dep, way, cog, gil);
u2_noun p_hax = u2h(hax);
u2_noun p_yor = u2h(yor);
u2_noun q_hax = u2t(hax);
u2_noun q_yor = u2t(yor);
2013-09-29 00:21:18 +04:00
u2_noun puq_hax, quq_hax;
u2_noun puq_yor, quq_yor;
u2_noun ret;
if ( u2_nul != q_hax ) {
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_hax, 6, &puq_hax, 7, &quq_hax, 0);
2013-09-29 00:21:18 +04:00
}
if ( u2_nul != q_yor ) {
2014-08-21 01:18:34 +04:00
u2_cr_mean(q_yor, 6, &puq_yor, 7, &quq_yor, 0);
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
if ( u2_yes == u2_cr_sing(hax, yor) ) {
ret = u2k(hax);
2013-12-31 23:30:37 +04:00
}
else {
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_sing(p_hax, p_yor)) ||
2013-12-31 23:30:37 +04:00
((u2_nul == q_hax) || (u2_nul == q_yor)) ||
2014-08-21 01:18:34 +04:00
(u2_no == u2_cr_sing(puq_hax, puq_yor)) ||
(u2_no == u2_cr_sing(u2h(quq_hax), u2h(quq_yor))) )
2013-12-31 23:30:37 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_error("find-fork");
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
switch ( u2h(quq_hax) ) {
2013-12-31 23:30:37 +04:00
case u2_yes: {
2014-08-21 01:18:34 +04:00
u2_noun pquq_hax = u2t(quq_hax);
u2_noun pquq_yor = u2t(quq_yor);
ret = u2nc
(
u2k(p_hax),
u2nq
(
2013-12-31 23:30:37 +04:00
u2_nul,
2014-08-21 01:18:34 +04:00
u2k(puq_hax),
2013-12-31 23:30:37 +04:00
u2_yes,
2014-09-03 07:36:29 +04:00
u2_cqf_fork(pquq_hax, pquq_yor)));
2013-12-31 23:30:37 +04:00
break;
2013-09-29 00:21:18 +04:00
}
2013-12-31 23:30:37 +04:00
case u2_no: {
u2_noun pquq_hax, qquq_hax, pquq_yor, qquq_yor;
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2_cx_cell(u2t(quq_hax), &pquq_hax, &qquq_hax);
u2_cx_cell(u2t(quq_yor), &pquq_yor, &qquq_yor);
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
if ( u2_no == u2_cr_sing(pquq_hax, pquq_yor) ) {
return u2_cm_error("find-fork");
2013-12-31 23:30:37 +04:00
} else {
2014-08-21 01:18:34 +04:00
ret = u2nc
(
u2k(p_hax),
u2nq
(u2_nul,
u2k(puq_hax),
2013-12-31 23:30:37 +04:00
u2_no,
2014-08-21 01:18:34 +04:00
u2nc
(u2k(pquq_hax),
2014-09-03 07:36:29 +04:00
u2_cqb_weld
2014-08-21 01:18:34 +04:00
(qquq_hax, qquq_yor))));
2013-12-31 23:30:37 +04:00
break;
2013-09-29 00:21:18 +04:00
}
}
}
}
2014-08-21 01:18:34 +04:00
u2z(yor);
u2z(hax);
2013-09-29 00:21:18 +04:00
return ret;
}
}
2014-08-21 01:18:34 +04:00
case c3__hold: p_sut = u2t(sut);
2013-09-29 00:21:18 +04:00
{
2014-09-03 07:36:29 +04:00
if ( (u2_yes == u2_cqdi_has(gil, sut)) ) {
2014-08-21 01:18:34 +04:00
return u2nc(u2k(dep), u2_nul);
}
2013-09-29 00:21:18 +04:00
else {
2014-09-03 07:36:29 +04:00
u2_noun zoc = u2_cqdi_put(gil, sut);
u2_noun fop = u2_cqfu_repo(van, sut);
2014-08-21 01:18:34 +04:00
u2_noun pro = _find_in(van, fop, dep, way, cog, zoc);
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(fop);
u2z(zoc);
2013-09-29 00:21:18 +04:00
return pro;
}
}
}
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
_cqfu_find(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog)
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return _find_in(van, sut, dep, way, cog, u2_nul);
2013-09-29 00:21:18 +04:00
}
2014-09-04 01:33:18 +04:00
u2_noun
_cqfu_fino(
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog)
2013-12-31 23:30:37 +04:00
{
2014-08-21 01:18:34 +04:00
return _fino_in(van, sut, dep, way, cog, u2_nul);
2013-12-31 23:30:37 +04:00
}
/* boilerplate
*/
2014-09-04 01:33:18 +04:00
u2_noun
u2_cwfu_fino(
u2_noun cor)
2013-12-31 23:30:37 +04:00
{
u2_noun sut, dep, way, cog, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &dep,
u2_cv_sam_6, &way,
u2_cv_sam_7, &cog,
u2_cv_con, &van,
2013-12-31 23:30:37 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-12-31 23:30:37 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-12-31 23:30:37 +04:00
} else {
2014-09-04 01:33:18 +04:00
return _cqfu_fino(van, sut, dep, way, cog);
2013-12-31 23:30:37 +04:00
}
}
2014-09-04 01:33:18 +04:00
u2_noun
u2_cqfu_fino(
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog)
2013-12-31 23:30:37 +04:00
{
2014-08-28 23:40:40 +04:00
c3_m fun_m = c3__fino;
u2_noun pro = u2_cz_find_4(fun_m, sut, dep, way, cog);
2013-12-31 23:30:37 +04:00
2014-08-28 23:40:40 +04:00
if ( u2_none != pro ) {
return pro;
2013-12-31 23:30:37 +04:00
}
else {
2014-09-04 01:33:18 +04:00
pro = _cqfu_fino(van, sut, dep, way, cog);
2013-12-31 23:30:37 +04:00
2014-08-28 23:40:40 +04:00
return u2_cz_save_4(fun_m, sut, dep, way, cog, pro);
2013-12-31 23:30:37 +04:00
}
}
2013-09-29 00:21:18 +04:00
/* boilerplate
*/
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
u2_cwfu_find(
2014-09-04 01:33:18 +04:00
u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun sut, dep, way, cog, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &dep,
u2_cv_sam_6, &way,
u2_cv_sam_7, &cog,
u2_cv_con, &van,
2013-09-29 00:21:18 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 09:46:55 +04:00
return _cqfu_find(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
}
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 07:36:29 +04:00
u2_cqfu_find(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog)
2013-09-29 00:21:18 +04:00
{
2014-08-28 23:40:40 +04:00
c3_m fun_m = c3__find;
u2_noun pro = u2_cz_find_4(fun_m, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
2014-08-28 23:40:40 +04:00
if ( u2_none != pro ) {
return pro;
2013-09-29 00:21:18 +04:00
}
else {
2014-09-03 09:46:55 +04:00
pro = _cqfu_find(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
2014-08-28 23:40:40 +04:00
return u2_cz_save_4(fun_m, sut, dep, way, cog, pro);
2013-09-29 00:21:18 +04:00
}
}