2013-12-18 05:47:20 +04:00
|
|
|
/* j/6/ut_conk.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2013-12-18 05:47:20 +04:00
|
|
|
|
|
|
|
/* logic
|
|
|
|
*/
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun
|
2014-10-28 20:36:22 +03:00
|
|
|
_cqfu_conk(u3_noun van, u3_noun sut, u3_noun got)
|
2013-12-21 02:26:23 +04:00
|
|
|
{
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3y == u3ud(got) ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3_cqf_face(got, sut);
|
2013-12-21 02:26:23 +04:00
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else switch ( u3h(got) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
default: return u3m_bail(c3__fail);
|
2013-12-21 02:26:23 +04:00
|
|
|
|
|
|
|
case 0: {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3k(sut);
|
2013-12-21 02:26:23 +04:00
|
|
|
}
|
|
|
|
case 1: {
|
2014-10-31 00:40:05 +03:00
|
|
|
u3_noun cok = _cqfu_conk(van, sut, u3t(u3t(got)));
|
|
|
|
u3_noun ret = u3_cqf_face(u3h(u3t(got)), cok);
|
|
|
|
|
|
|
|
u3z(cok);
|
|
|
|
return ret;
|
2013-12-21 02:26:23 +04:00
|
|
|
}
|
|
|
|
case 2: {
|
2014-11-06 06:10:22 +03:00
|
|
|
u3_noun vet = u3r_at(u3_cqfu_van_vet, van);
|
2014-10-28 20:36:22 +03:00
|
|
|
u3_noun hed, tal, deh, lat, ret;
|
2013-12-21 02:26:23 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3y == vet ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun cel = u3nt(c3__cell, c3__noun, c3__noun);
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3_cqfu_nest(van, cel, c3y, sut) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2013-12-21 02:26:23 +04:00
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(cel);
|
2013-12-21 02:26:23 +04:00
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
hed = u3_cqfu_peek(van, sut, c3__both, 2);
|
|
|
|
tal = u3_cqfu_peek(van, sut, c3__both, 3);
|
2014-10-28 20:36:22 +03:00
|
|
|
deh = _cqfu_conk(van, hed, u3h(u3t(got)));
|
|
|
|
lat = _cqfu_conk(van, tal, u3t(u3t(got)));
|
2013-12-21 02:26:23 +04:00
|
|
|
|
2014-10-28 20:36:22 +03:00
|
|
|
ret = u3_cqf_cell(deh, lat);
|
2013-12-21 02:26:23 +04:00
|
|
|
|
2014-10-28 20:36:22 +03:00
|
|
|
u3z(lat);
|
|
|
|
u3z(deh);
|
2014-09-06 00:13:24 +04:00
|
|
|
u3z(tal);
|
2014-10-28 20:36:22 +03:00
|
|
|
u3z(hed);
|
2013-12-21 02:26:23 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 05:47:20 +04:00
|
|
|
/* boilerplate
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
|
|
|
u3_cwfu_conk(u3_noun cor)
|
2013-12-18 05:47:20 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut, got, van;
|
2013-12-18 05:47:20 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( (c3n == u3r_mean(cor, u3v_sam, &got,
|
|
|
|
u3v_con, &van,
|
2013-12-18 05:47:20 +04:00
|
|
|
0)) ||
|
2014-11-06 03:20:01 +03:00
|
|
|
(u3_none == (sut = u3r_at(u3v_sam, van))) )
|
2013-12-18 05:47:20 +04:00
|
|
|
{
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2013-12-18 05:47:20 +04:00
|
|
|
} else {
|
2014-09-03 09:46:55 +04:00
|
|
|
return _cqfu_conk(van, sut, got);
|
2013-12-18 05:47:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
|
|
|
u3_cqfu_conk(u3_noun van,
|
|
|
|
u3_noun sut,
|
|
|
|
u3_noun got)
|
2013-12-18 05:47:20 +04:00
|
|
|
{
|
2014-09-03 09:46:55 +04:00
|
|
|
return _cqfu_conk(van, sut, got);
|
2013-12-18 05:47:20 +04:00
|
|
|
}
|
|
|
|
|