shrub/jets/f/ut_fink.c

107 lines
2.4 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/fink.c
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
/* logic
*/
2015-11-29 00:08:52 +03:00
static u3_noun
_fink_flee(u3_noun poy)
{
u3_noun p_poy = u3h(poy);
u3_noun q_poy = u3t(poy);
switch ( u3h(q_poy) ) {
default: return u3m_bail(c3__fail);
case 0: {
u3_noun pq_poy = u3t(q_poy);
return u3nt(u3k(p_poy), c3y, u3k(pq_poy));
}
case 1: {
u3_noun pq_poy = u3h(u3t(q_poy));
u3_noun qq_poy = u3t(u3t(q_poy));
return u3nq(u3k(p_poy), c3n, u3k(pq_poy), u3k(qq_poy));
}
case 2: {
u3_noun pq_poy = u3h(u3t(q_poy));
// u3_noun qq_poy = u3t(u3t(q_poy));
// u3_noun ppq_poy = u3h(pq_poy);
// u3_noun qpq_poy = u3h(u3t(pq_poy));
u3_noun rpq_poy = u3h(u3t(u3t(pq_poy)));
u3_noun spq_poy = u3t(u3t(u3t(pq_poy)));
return u3nt(u3qc_peg(p_poy, rpq_poy), c3y, u3k(spq_poy));
}
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
_cqfu_fink(u3_noun van,
u3_noun sut,
u3_noun dep,
u3_noun way,
2015-11-29 00:08:52 +03:00
u3_noun cug)
2013-09-29 00:21:18 +04:00
{
2014-11-18 00:56:51 +03:00
// u3_noun dun = u3qfu_dunq(van, "type", sut);
2015-11-29 00:08:52 +03:00
u3_noun nuc = (u3_blip == cug)
2015-08-28 19:34:36 +03:00
? u3qfu_shew(van,
u3nc(u3nc('c',
u3i_string("find-limb")),
'$'))
2015-11-29 00:08:52 +03:00
: u3qfu_shep(van, "find-limb", 'a', u3k(cug));
2014-09-06 00:13:24 +04:00
u3_noun pro;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
// u3t_push(u3nc(c3__mean, dun));
2014-11-06 03:20:01 +03:00
u3t_push(u3nc(c3__mean, nuc));
2013-09-29 00:21:18 +04:00
{
2015-11-29 00:11:09 +03:00
u3_noun hoq = u3qfu_find(van, sut, dep, way, cug);
2014-09-06 00:13:24 +04:00
u3_noun fin = u3t(hoq);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
if ( u3_nul == fin ) {
2015-11-29 00:08:52 +03:00
// u3m_p("cug", cug);
2014-11-06 03:20:01 +03:00
return u3m_error("find-none");
2013-09-29 00:21:18 +04:00
}
else {
2015-11-29 00:08:52 +03:00
pro = _fink_flee(u3t(fin));
2014-09-06 00:13:24 +04:00
u3z(hoq);
2013-09-29 00:21:18 +04:00
}
}
2014-11-18 00:56:51 +03:00
// u3t_drop();
2014-11-06 03:20:01 +03:00
u3t_drop();
2013-09-29 00:21:18 +04:00
return pro;
}
/* boilerplate
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wfu_fink(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2015-11-29 00:08:52 +03:00
u3_noun sut, dep, way, cug, 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, &dep,
2015-08-28 19:34:36 +03:00
u3x_sam_6, &way,
2015-11-29 00:08:52 +03:00
u3x_sam_7, &cug,
2015-08-28 19:34:36 +03:00
u3x_con, &van,
0)) ||
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 {
2015-11-29 00:08:52 +03:00
return _cqfu_fink(van, sut, dep, way, cug);
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
u3qfu_fink(u3_noun van,
u3_noun sut,
u3_noun dep,
u3_noun way,
2015-11-29 00:08:52 +03:00
u3_noun cug)
2013-09-29 00:21:18 +04:00
{
2015-11-29 00:08:52 +03:00
return _cqfu_fink(van, sut, dep, way, cug);
2013-09-29 00:21:18 +04:00
}