/* logic */ u3_noun u3qfu_repo( u3_noun van, u3_noun sut) { u3_noun p_sut, q_sut; if ( c3n == u3du(sut) ) switch ( sut ) { default: return u3k(sut); case c3__noun: return u3nt(c3__fork, u3nc(c3__atom, u3_blip), u3nt(c3__cell, c3__noun, c3__noun)); } else switch ( u3h(sut) ) { default: { return u3m_error("repo-flat"); } case c3__bull: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__core: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut) ) { return u3m_bail(c3__fail); } else { return u3nt(c3__cell, c3__noun, u3k(p_sut)); } } case c3__cube: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__face: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__hold: { p_sut = u3t(sut); return u3qfu_rest(van, sut, p_sut); } } }
static u3_noun _nest_dext_in( u3_noun van, u3_noun sut, u3_noun tel, u3_noun ref, u3_noun gil) { u3_noun p_sut, q_sut, p_ref, q_ref; if ( (c3n == u3du(sut)) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: { return c3y; } case c3__void: { return _nest_sint(van, sut, tel, ref, gil); } } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: { if ( (c3y == u3du(ref)) && (c3__atom == u3h(ref)) ) { if ( c3n == u3qf_fitz(u3t(sut), u3t(ref)) ) { // u3_err("fitz: need", u3t(sut)); // u3_err("fitz: have", u3t(ref)); return c3n; } return c3y; } else return _nest_sint(van, sut, tel, ref, gil); } case c3__bull: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _nest_dext(van, q_sut, tel, ref, gil); } } case c3__cell: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) { return c3a(_nest_dext(van, p_sut, tel, p_ref, gil), _nest_dext(van, q_sut, tel, q_ref, gil)); } else return _nest_sint(van, sut, tel, ref, gil); } } case c3__core: { if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) { return u3m_bail(c3__fail); } else { if ( (c3y == u3r_pq(ref, c3__core, &p_ref, &q_ref)) ) { return _nest_cong(van, sut, tel, ref, gil); } else return _nest_sint(van, sut, tel, ref, gil); } } case c3__cube: { if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) { return u3m_bail(c3__fail); } else { if ( c3y == u3r_pq(ref, c3__cube, &p_ref, &q_ref) ) { return u3r_sing(p_sut, p_ref); } else return _nest_sint(van, sut, tel, ref, gil); } } case c3__face: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _nest_dext(van, q_sut, tel, ref, gil); } } case c3__fork: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { if ( c3n == u3du(ref) ) switch ( ref ) { default: return _nest_sint(van, sut, tel, ref, gil); case c3__noun: break; } else switch ( u3h(ref) ) { default: return _nest_sint(van, sut, tel, ref, gil); case c3__atom: case c3__cell: case c3__cube: case c3__core: break; } return c3o(_nest_dext(van, p_sut, c3n, ref, gil), _nest_dext(van, q_sut, c3n, ref, gil)); } } case c3__hold: p_sut = u3t(sut); { u3_noun hud = u3nc(u3k(sut), u3k(ref)); if ( (c3y == u3qdi_has(gil, hud)) ) { u3z(hud); return c3y; } else { u3_noun zoc = u3qdi_put(gil, hud); u3_noun fop = u3qfu_rest(van, sut, p_sut); u3_noun hiv = _nest_dext(van, fop, tel, ref, zoc); u3z(hud); u3z(fop); u3z(zoc); return hiv; } } } }