/* logic */ static u3_noun _cqfu_conk(u3_noun van, u3_noun sut, u3_noun got) { if ( c3y == u3ud(got) ) { u3_noun ret = u3qf_face(u3k(got), sut); return ret; } else switch ( u3h(got) ) { default: return u3m_bail(c3__fail); case 0: { return u3k(sut); } case 1: { u3_noun c*k = _cqfu_conk(van, sut, u3t(u3t(got))); u3_noun nux = u3k(u3h(u3t(got))); u3_noun ret = u3qf_face(nux, c*k); u3z(nux); u3z(c*k); return ret; } case 2: { u3_noun vet = u3r_at(u3qfu_van_vet, van); u3_noun hed, tal, deh, lat, ret; if ( c3y == vet ) { u3_noun cel = u3nt(c3__cell, c3__noun, c3__noun); if ( c3n == u3qfu_nest(van, cel, c3y, sut) ) { return u3m_bail(c3__fail); } u3z(cel); } hed = u3qfu_peek(van, sut, c3__both, 2); tal = u3qfu_peek(van, sut, c3__both, 3); deh = _cqfu_conk(van, hed, u3h(u3t(got))); lat = _cqfu_conk(van, tal, u3t(u3t(got))); ret = u3qf_cell(deh, lat); u3z(lat); u3z(deh); u3z(tal); u3z(hed); return ret; } } }
u3_noun u3wf_face(u3_noun cor) { u3_noun sag, tip; if ( c3n == u3r_mean(cor, u3x_sam_2, &sag, u3x_sam_3, &tip, 0) ) { return u3m_bail(c3__fail); } else { return u3qf_face(sag, tip); } }
static u3_noun _heal_to( u3_noun van, u3_noun sut, u3_noun gil, u3_noun qog, u3_noun ref, u3_atom now, u3_atom lat) { u3_noun p_sut, q_sut; if ( c3n == u3du(sut) ) { goto repo; } else switch ( u3h(sut) ) { default: goto repo; case c3__atom: return c3__void; case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun sub = _heal_to(van, q_sut, gil, qog, ref, now, lat); u3_noun ret; ret = u3qfu_busk (van, sub, u3h(p_sut), u3h(u3t(p_sut))); u3z(sub); return ret; } case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun ter, ret; if ( 2 == now ) { ter = _heal_as(van, p_sut, qog, lat, ref); ret = u3qf_cell(ter, q_sut); } else { ter = _heal_as(van, q_sut, qog, lat, ref); ret = u3qf_cell(p_sut, ter); } u3z(ter); return ret; } case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( 3 != now ) { return u3m_error("heal-core"); } else { u3_noun ter = _heal_as(van, p_sut, qog, lat, ref); u3_noun ret = u3qf_core(ter, q_sut); u3z(ter); return ret; } } case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun dun = _heal_to(van, q_sut, gil, qog, ref, now, lat); u3_noun ret = u3qf_face(p_sut, dun); u3z(dun); return ret; } case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun dis = _heal_to(van, p_sut, gil, qog, ref, now, lat); u3_noun dat = _heal_to(van, q_sut, gil, qog, ref, now, lat); u3_noun ret = u3qf_fork(dis, dat); u3z(dis); u3z(dat); return ret; } case c3__hold: { if ( (c3y == u3qdi_has(gil, sut)) ) { return c3__void; } else { u3_noun zoc = u3qdi_put(gil, sut); u3_noun rep = u3qfu_repo(van, sut); u3_noun ret = _heal_to(van, rep, zoc, qog, ref, now, lat); u3z(rep); u3z(zoc); return ret; } } } repo: { u3_noun rep = u3qfu_repo(van, sut); u3_noun ret = _heal_to(van, rep, gil, qog, ref, now, lat); u3z(rep); return ret; } }
static u3_noun _heal_by( u3_noun van, u3_noun sut, u3_noun qog, u3_noun ref) { u3_noun p_sut, q_sut; if ( c3n == u3du(sut) ) { return u3m_error("heal-name"); } else switch ( u3h(sut) ) { default: return u3m_error("heal-name"); case c3__core: { return u3k(ref); } case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( c3y == u3r_sing(u3h(p_sut), u3t(qog)) ) { return u3k(ref); } else { u3_noun sub = _heal_by(van, q_sut, qog, ref); u3_noun ret; ret = u3qfu_busk (van, sub, u3h(p_sut), u3h(u3t(p_sut))); u3z(sub); return ret; } } case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( c3y == u3r_sing(p_sut, u3t(qog)) ) { return u3qf_face(p_sut, ref); } else return u3m_error("heal-name"); } case c3__hold: { u3_noun rep = u3qfu_repo(van, sut); u3_noun ret = _heal_by(van, rep, qog, ref); u3z(rep); return ret; } case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun dis = _heal_by(van, p_sut, qog, ref); u3_noun dat = _heal_by(van, q_sut, qog, ref); u3_noun ret = u3qf_fork(dis, dat); u3z(dis); u3z(dat); return ret; } } }
static u3_noun _fuse_in(u3_noun van, u3_noun sut, u3_noun ref, u3_noun bix) { u3_noun p_sut, q_sut; if ( c3y == u3r_sing(sut, ref) || (c3__noun == ref) ) { return u3k(sut); } if ( c3n == u3du(sut) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: { return u3k(ref); } case c3__void: { return c3__void; } } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( c3y == u3du(ref) ) { if ( c3__atom == u3h(ref) ) { u3_noun p_ref, q_ref; u3x_cell(u3t(ref), &p_ref, &q_ref); { u3_noun foc = (c3y == u3qf_fitz(p_ref, p_sut)) ? u3k(p_sut) : u3k(p_ref); if ( c3y == u3du(q_sut) ) { if ( c3y == u3du(q_ref) ) { if ( c3y == u3r_sing(q_ref, q_sut) ) { return u3nt(c3__atom, foc, u3k(q_sut)); } else { u3z(foc); return c3__void; } } else { return u3nt(c3__atom, foc, u3k(q_sut)); } } else { return u3nt(c3__atom, foc, u3k(q_ref)); } } } else if ( c3__cell == u3h(ref) ) { return c3__void; } } return _fuse_in(van, ref, sut, bix); } case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun p_ref, q_ref; if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) { u3_noun hed = _fuse_in(van, p_sut, p_ref, bix); u3_noun tal = _fuse_in(van, q_sut, q_ref, bix); u3_noun ret = u3qf_cell(hed, tal); u3z(hed); u3z(tal); return ret; } else return _fuse_in(van, ref, sut, bix); } case c3__core: { return _fuse_repo(van, sut, ref, bix); } case c3__help: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun vot = _fuse_in(van, q_sut, ref, bix); u3_noun ret = u3qf_help(p_sut, vot); u3z(vot); return ret; } case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun vot = _fuse_in(van, q_sut, ref, bix); u3_noun ret = u3qf_face(p_sut, vot); u3z(vot); return ret; } case c3__fork: p_sut = u3t(sut); { u3_noun yed = u3qdi_tap(p_sut); u3_noun ret = u3kf_fork(_fuse_in_fork(van, yed, ref, bix)); u3z(yed); return ret; } case c3__hold: { u3_noun hud = u3nc(u3k(sut), u3k(ref)); if ( c3y == u3qdi_has(bix, hud) ) { // u3_noun dun = u3qfu_dunq(van, "type", sut); // u3_noun niz = u3qfu_dunq(van, "over", ref); // u3t_push(u3nc(c3__mean, dun)); // u3t_push(u3nc(c3__mean, niz)); return u3m_error("fuse-loop"); } else { u3_noun bux = u3qdi_put(bix, hud); u3_noun ret = _fuse_repo(van, sut, ref, bux); u3z(hud); u3z(bux); return ret; } } } }
static u3_noun _play_in(u3_noun van, u3_noun sut, u3_noun gen) { u3_noun p_gen, q_gen, r_gen; if ( c3n == u3du(gen) ) { open: { u3_noun fab = u3r_at(u3qfu_van_fab, van); u3_noun ter = u3r_at(u3x_con_3, van); u3_noun rex = (c3n == fab) ? u3qfp_nepo(ter, gen) : u3qfp_open(ter, gen); u3_noun ret; if ( c3y == u3r_sing(rex, gen) ) { u3_noun zix = u3qfu_shep(van, "gene", 'q', u3k(gen)); u3t_push(u3nc(c3__mean, zix)); return u3m_error("play-open-z"); } ret = _play_x(van, sut, rex); u3z(rex); return ret; } } else if ( c3y == u3du(u3h(gen)) ) { _play_used(); { u3_noun dis = _play_x(van, sut, u3h(gen)); u3_noun dat = _play_x(van, sut, u3t(gen)); u3_noun ret = u3qf_cell(dis, dat); u3z(dis); u3z(dat); return ret; } } else switch ( u3h(gen) ) { default: goto open; case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_bean(); } case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); _play_used(); { u3_noun fex = u3qfu_gain(van, sut, p_gen); u3_noun wux = u3qfu_lose(van, sut, p_gen); u3_noun dez = (fex == c3__void) ? c3__void : _play_x(van, fex, q_gen); u3_noun doz = (wux == c3__void) ? c3__void : _play_x(van, wux, r_gen); u3_noun ret = u3qf_forq(dez, doz); u3z(dez); u3z(doz); u3z(fex); u3z(wux); return ret; } case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun dis = _play_x(van, sut, p_gen); u3_noun dat = _play_x(van, sut, q_gen); u3_noun ret = u3qf_cell(dis, dat); u3z(dis); u3z(dat); return ret; } case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun nog = u3nc(c3__bunt, u3k(p_gen)); u3_noun ret = _play_x(van, sut, nog); u3z(nog); return ret; } case c3__dtwt: p_gen = u3t(gen); _play_used(); { return _play_bean(); } case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_bean(); } case c3__dtls: p_gen = u3t(gen); _play_used(); { return u3nt(c3__atom, u3_blip, u3_nul); } case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_rock(p_gen, q_gen); } case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return c3__noun; } case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_sand(p_gen, q_gen); } case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return u3k(p_gen); } case c3__ktbr: p_gen = u3t(gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); u3_noun pro = u3qfu_wrap(van, boc, c3__iron); u3z(boc); return pro; } case c3__ktpm: p_gen = u3t(gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); u3_noun pro = u3qfu_wrap(van, boc, c3__zinc); u3z(boc); return pro; } case c3__ktwt: p_gen = u3t(gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); u3_noun pro = u3qfu_wrap(van, boc, c3__lead); u3z(boc); return pro; } case c3__help: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun boc = _play_x(van, sut, q_gen); u3_noun ret = u3qf_help(p_gen, boc); u3z(boc); return ret; } case c3__docs: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun boc = _play_x(van, sut, q_gen); u3_noun hep = u3nc(c3__docs, u3k(p_gen)); u3_noun ret = u3qf_help(hep, boc); u3z(hep); u3z(boc); return ret; } case c3__ktts: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun boc = _play_x(van, sut, q_gen); u3_noun ret = u3qfu_conk(van, boc, p_gen); u3z(boc); return ret; } case c3__tune: p_gen = u3t(gen); _play_used(); { return u3qf_face(p_gen, sut); } case c3__ktsg: p_gen = u3t(gen); _play_used(); { return _play_x(van, sut, p_gen); } case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_x(van, sut, p_gen); } case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); u3_noun ret = _play_x(van, boc, q_gen); u3z(boc); return ret; } case c3__tstr: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); _play_used(); { u3_noun boc = u3qfu_buss(van, sut, p_gen, q_gen); u3_noun ret = _play_x(van, boc, r_gen); u3z(boc); return ret; } case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun boc = u3qfu_busk(van, sut, p_gen); u3_noun ret = _play_x(van, boc, q_gen); u3z(boc); return ret; } case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_cnts(van, sut, p_gen, q_gen); } case c3__brcn: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun ruf = u3nc(u3_nul, 1); u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen, q_gen); u3z(ruf); return ret; } case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun typ = u3qfu_play(van, sut, p_gen); u3_noun dug = u3qfu_duck(van, typ); u3_noun ret; u3t_push(u3nc(c3__mean, dug)); { ret = _play_x(van, sut, q_gen); } u3t_drop(); u3z(typ); return ret; } case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_x(van, sut, q_gen); } case c3__zpts: p_gen = u3t(gen); _play_used(); { return c3__noun; } case c3__ktcn: p_gen = u3t(gen); { u3_noun von = u3i_molt(u3k(van), u3qfu_van_fab, c3n, 0); u3_noun ret = _play_x(von, sut, p_gen); u3z(von); return ret; } case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { return _play_x(van, sut, p_gen); } case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen); { u3_noun ret; #if 0 { u3_noun cog = _play_loc_term(van, p_gen); u3t_heck(cog); u3z(cog); } #endif u3t_push(u3nc(c3__mean, _play_loc(van, p_gen))); { ret = _play_x(van, sut, q_gen); } u3t_drop(); return ret; } case c3__zpmc: case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen); _play_used(); { u3_noun zur = _play_x(van, sut, p_gen); u3_noun vos = _play_x(van, sut, q_gen); u3_noun ret = u3qf_cell(zur, vos); u3z(zur); u3z(vos); return ret; } case c3__lost: case c3__fail: case c3__zpzp: _play_used(); { return c3__void; } } }
static u3_noun _cull_in(u3_noun van, u3_noun sut, u3_noun pol, u3_atom axe, u3_noun ref, u3_noun now, u3_noun lat, u3_noun vil) { u3_noun ret, p_sut, q_sut; if ( c3n == u3du(sut) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: { u3_noun pyr = u3qfu_repo(van, sut); u3_noun yot = _cqfu_cull(van, pyr, pol, axe, ref); if ( c3y == u3r_sing(pyr, yot) ) { ret = u3k(sut); } else { ret = u3k(yot); } u3z(pyr); u3z(yot); break; } case c3__void: { ret = c3__void; } } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: { ret = c3__void; break; } case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun hic = _cqfu_cull(van, q_sut, pol, axe, ref); if ( c3y == u3r_sing(hic, q_sut) ) { ret = u3k(sut); } else { ret = u3qf_bull(p_sut, hic); } u3z(hic); break; } case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun hub; if ( 2 == now ) { hub = _cqfu_cull(van, p_sut, pol, lat, ref); ret = u3qf_cell(hub, q_sut); } else { hub = _cqfu_cull(van, q_sut, pol, lat, ref); ret = u3qf_cell(p_sut, hub); } u3z(hub); break; } case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( 3 != now ) { ret = u3k(sut); } else { u3_noun hub = _cqfu_cull(van, p_sut, pol, lat, ref); ret = u3qf_core(hub, q_sut); u3z(hub); } break; } case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun hic = _cqfu_cull(van, q_sut, pol, axe, ref); if ( c3y == u3r_sing(hic, q_sut) ) { ret = u3k(sut); } else { ret = u3qf_face(p_sut, hic); } u3z(hic); break; } case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( c3y == u3qdi_has(vil, sut) ) { return c3__void; } else { u3_noun zoc = u3qdi_put(vil, sut); u3_noun sin = _cull_in(van, p_sut, pol, axe, ref, now, lat, zoc); u3_noun dex = _cull_in(van, q_sut, pol, axe, ref, now, lat, zoc); ret = u3qf_fork(sin, dex); u3z(sin); u3z(dex); u3z(zoc); return ret; } } case c3__cube: case c3__hold: { u3_noun pyr = u3qfu_repo(van, sut); u3_noun yot = _cull_in(van, pyr, pol, axe, ref, now, lat, vil); if ( c3y == u3r_sing(pyr, yot) ) { if ( c3__void == pyr ) { ret = c3__void; } else ret = u3k(sut); } else { ret = u3k(yot); } u3z(pyr); u3z(yot); break; } } u3z(lat); return ret; }
static u3_noun _crop_dext( u3_noun van, u3_noun sut, u3_noun ref, u3_noun bix) { u3_noun p_sut, q_sut, p_ref, q_ref; if ( c3n == u3du(ref) ) { switch ( ref ) { case c3__void: return u3k(sut); case c3__noun: return c3__void; default: return u3m_bail(c3__fail); } } if ( c3y == u3r_sing(sut, ref) ) { return c3__void; } if ( c3n == u3du(sut) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: return _crop_repo(van, sut, ref, bix); case c3__void: return c3__void; } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: { if ( c3__atom == u3h(ref) ) { return c3__void; } else if ( c3__cell == u3h(ref) ) { return u3k(sut); } else return _crop_sint(van, sut, ref, bix); } case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun foz = _crop_dext(van, q_sut, ref, bix); u3_noun ret = u3qf_bull(p_sut, foz); u3z(foz); return ret; } case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( c3__atom == u3h(ref) ) { return u3k(sut); } else if ( c3__cell == u3h(ref) ) { u3x_cell(u3t(ref), &p_ref, &q_ref); if ( c3y == u3qfu_nest (van, p_ref, c3n, p_sut) ) { u3_noun foz = _crop_dext(van, q_sut, q_ref, bix); u3_noun ret = u3qf_cell(p_sut, foz); u3z(foz); return ret; } else return u3k(sut); } else return _crop_sint(van, sut, ref, bix); } case c3__core: { if ( (c3__atom == u3h(ref)) || (c3__cell == u3h(ref)) ) { return u3k(sut); } else return _crop_sint(van, sut, ref, bix); } case c3__cube: u3x_cell(u3t(sut), &p_sut, &q_sut); { if ( (c3__cube == u3h(ref)) && (c3y == u3r_sing(p_sut, u3h(u3t(ref)))) ) { return c3__void; } else if ( (c3__atom == u3h(ref)) || (c3__cell == u3h(ref)) ) { u3_noun foz = _crop_dext(van, q_sut, ref, bix); u3_noun ret; if ( c3y == u3qfu_firm(van, foz, p_sut) ) { ret = u3qf_cube(p_sut, foz); } else ret = c3__void; u3z(foz); return ret; } else return _crop_sint(van, sut, ref, bix); } case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun foz = _crop_dext(van, q_sut, ref, bix); u3_noun ret = u3qf_face(p_sut, foz); u3z(foz); return ret; } case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut); { u3_noun dis = _crop_dext(van, p_sut, ref, bix); u3_noun dat = _crop_dext(van, q_sut, ref, bix); u3_noun ret = u3qf_fork(dis, dat); u3z(dis); u3z(dat); return ret; } case c3__hold: p_sut = u3t(sut); { u3_noun hud = u3nc(u3k(sut), u3k(ref)); if ( c3y == u3qdi_has(bix, hud) ) { # if 0 u3_noun dun = u3qfu_dunq(van, "type", sut); u3_noun niz = u3qfu_dunq(van, "over", ref); u3t_push(u3nc(c3__mean, dun)); u3t_push(u3nc(c3__mean, niz)); # endif return u3m_error("crop-loop"); } else { u3_noun bux = u3qdi_put(bix, hud); u3_noun ret = _crop_repo(van, sut, ref, bux); u3z(hud); u3z(bux); return ret; } } } }