2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/ut_repo.c
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/* logic
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
2015-08-28 19:34:36 +03:00
|
|
|
u3qfu_repo(u3_noun van,
|
|
|
|
u3_noun sut)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun p_sut, q_sut;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
if ( c3n == u3du(sut) ) switch ( sut ) {
|
2014-09-06 00:13:24 +04:00
|
|
|
default: return u3k(sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2016-01-13 21:06:42 +03:00
|
|
|
case c3__noun: {
|
2016-01-14 12:52:50 +03:00
|
|
|
return u3kf_fork(u3nt(u3nt(c3__atom, u3_blip, u3_nul),
|
2016-01-13 21:06:42 +03:00
|
|
|
u3nt(c3__cell, c3__noun, c3__noun),
|
|
|
|
u3_nul));
|
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-09-06 00:13:24 +04:00
|
|
|
else switch ( u3h(sut) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
default: {
|
2016-01-13 21:06:42 +03:00
|
|
|
u3m_p("head", u3h(sut));
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_error("repo-flat");
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case c3__core: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut) ) {
|
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3nt(c3__cell, c3__noun, u3k(p_sut));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2016-01-15 07:37:58 +03:00
|
|
|
case c3__fuss:
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__face: {
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) {
|
|
|
|
return u3m_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-06 00:13:24 +04:00
|
|
|
return u3k(q_sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
2016-01-11 10:04:34 +03:00
|
|
|
case c3__hold: {
|
2016-01-11 09:37:59 +03:00
|
|
|
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) {
|
|
|
|
return u3m_bail(c3__fail);
|
|
|
|
} else {
|
|
|
|
u3_noun old = u3nc(u3nc(u3k(p_sut), u3k(q_sut)), u3_nul);
|
|
|
|
u3_noun ret;
|
|
|
|
|
|
|
|
ret = u3qfu_rest(van, sut, old);
|
|
|
|
u3z(old);
|
|
|
|
return ret;
|
|
|
|
}
|
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
|
|
|
u3wfu_repo(u3_noun cor)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun sut;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-11-18 00:56:51 +03:00
|
|
|
if ( u3_none == (sut = u3r_at(u3x_sam, cor)) ) {
|
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 u3qfu_repo(cor, sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|