Beispiel #1
0
  u3_noun
  u3wfu_repo(
                       u3_noun cor)
  {
    u3_noun sut;

    if ( u3_none == (sut = u3r_at(u3x_sam, cor)) ) {
      return u3m_bail(c3__fail);
    } else {
      return u3qfu_repo(cor, sut);
    }
  }
Beispiel #2
0
  static u3_noun
  _crop_sint(
             u3_noun van,
             u3_noun sut,
             u3_noun ref,
             u3_noun bix)
  {
    u3_noun p_ref, q_ref;

    switch ( u3h(ref) ) {
      default: return u3m_bail(c3__fail);

      case c3__bull: u3x_cell(u3t(ref), &p_ref, &q_ref);
      {
        return _crop_dext(van, sut, q_ref, bix);
      }
      case c3__core:
      case c3__cube: {
        return u3k(sut);
      }
      case c3__face: u3x_cell(u3t(ref), &p_ref, &q_ref);
      {
        return _crop_dext(van, sut, q_ref, bix);
      }
      case c3__fork: u3x_cell(u3t(ref), &p_ref, &q_ref);
      {
        u3_noun hin = _crop_dext(van, sut, p_ref, bix);
        u3_noun ret = _crop_dext(van, hin, q_ref, bix);

        u3z(hin);
        return ret;
      }
      case c3__hold: p_ref = u3t(ref);
      {
        u3_noun rep = u3qfu_repo(van, ref);
        u3_noun ret = _crop_dext(van, sut, rep, bix);

        u3z(rep);
        return ret;
      }
    }
  }
Beispiel #3
0
  static u3_noun
  _fuse_repo(u3_noun van,
             u3_noun sut,
             u3_noun ref,
             u3_noun bix)
  {
    u3_noun rep = u3qfu_repo(van, sut);
    u3_noun ret = _fuse_in(van, rep, ref, bix);

    if ( c3y == u3r_sing(ret, rep) ) {
      if ( c3__void == rep ) {
        return c3__void;
      } else {
        u3z(rep);
        u3z(ret);
        return u3k(sut);
      }
    } else {
      u3z(rep);
      return ret;
    }
  }
Beispiel #4
0
  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;
    }
  }
Beispiel #5
0
  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;
      }
    }
  }
Beispiel #6
0
  static u3_noun
  _nest_sint(
             u3_noun van,
             u3_noun sut,
             u3_noun tel,
             u3_noun ref,
             u3_noun gil)
  {
    u3_noun p_ref, q_ref;

    if ( (c3n == u3du(ref)) ) {
      switch ( ref ) {
        default: return u3m_bail(c3__fail);

        case c3__noun: return c3n;
        case c3__void: return c3y;
      }
    }
    else {
      switch ( u3h(ref) ) {
        default: {
          return u3m_bail(c3__fail);
        }
        case c3__atom: return c3n;
        case c3__bull: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__cell: return c3n;
        case c3__core: {
          u3_noun gam = u3qfu_repo(van, ref);
          u3_noun hiv = _nest_dext(van, sut, tel, gam, gil);

          u3z(gam);
          return hiv;
        }
        case c3__cube: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__face: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__fork: {
          if ( (c3y == u3r_mean(ref, 6, &p_ref, 7, &q_ref, 0)) ) {
            return c3a(_nest_dext(van, sut, c3n, p_ref, gil),
                          _nest_dext(van, sut, c3n, q_ref, gil));
          }
          else return u3m_bail(c3__fail);
        }
        case c3__hold: {
          p_ref = u3t(ref);
          {
            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 gam = u3qfu_repo(van, ref);

              {
                u3_noun hiv = _nest_dext(van, sut, tel, gam, zoc);

                u3z(hud);
                u3z(gam);
                u3z(zoc);

                return hiv;
              }
            }
          }
        }
      }
    }
  }
Beispiel #7
0
  static u3_noun
  _fish_in(u3_noun van,
           u3_noun sut,
           u3_atom axe,
           u3_noun vit)
  {
    u3_noun p_sut, q_sut;

    if ( c3y == u3ud(sut) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: {
        return u3nc(1, 0);
      }
      case c3__void: {
        return u3nc(1, 1);
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          if ( c3n == u3du(q_sut) ) {
            u3_noun ton = u3nt(3, 0, u3k(axe));
            u3_noun pro = u3qf_flip(ton);

            u3z(ton);
            return pro;
          } else {
            return u3nt(5,
                        u3nc(1, u3k(u3t(q_sut))),
                        u3nc(0, u3k(axe)));
          }
        }
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_noun hut = u3nt(3, 0, u3k(axe));
          u3_noun lef = u3qc_peg(axe, 2);
          u3_noun rit = u3qc_peg(axe, 3);
          u3_noun hed = _fish_in(van, p_sut, lef, vit);
          u3_noun tal = _fish_in(van, q_sut, rit, vit);
          u3_noun hob = u3qf_flan(hed, tal);
          u3_noun vug = u3qf_flan(hut, hob);

          u3z(hob);
          u3z(tal);
          u3z(hed);
          u3z(rit);
          u3z(lef);
          u3z(hut);

          return vug;
        }
      }
      case c3__core: {
        return u3nc(0, 0);
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _fish_in(van, q_sut, axe, vit);
        }
      }
      case c3__fork: p_sut = u3t(sut);
      {
        u3_noun yed = u3qdi_tap(p_sut, u3_nul);
        u3_noun ret = _fish_fork(van, yed, axe, vit);

        u3z(yed);
        return ret;
      }
      case c3__hold: {
        p_sut = u3t(sut);
        {
          if ( (c3y == u3qdi_has(vit, sut)) ) {
            //  u3_noun dun = u3qfu_dunq(van, "type", sut);
            u3_noun niz = u3qfu_shep
              (van, "axis", 'd', u3k(axe));

            //  u3t_push(u3nc(c3__mean, dun));
            u3t_push(u3nc(c3__mean, niz));

            return u3m_error("fish-loop");
          } else {
            u3_noun zoc = u3qdi_put(vit, sut);
            u3_noun fop = u3qfu_repo(van, sut);
            u3_noun pro = _fish_in(van, fop, axe, zoc);

            u3z(fop);
            u3z(zoc);

            return pro;
          }
        }
      }
    }
  }
Beispiel #8
0
  static u3_noun
  _peek_in(u3_noun van,
           u3_noun sut,
           u3_noun way,
           u3_atom axe,
           u3_noun gil)
  {
    u3_noun p_sut, q_sut;
    u3_noun pro;

    if ( (c3n == u3du(sut)) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: {
        return c3__noun;
      }
      case c3__void: {
        return c3__void;
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        return c3__void;
      }
      case c3__bull: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_atom tip = u3qc_cap(axe);
          u3_atom tap = u3qc_mas(axe);

          if ( 2 == tip ) {
            pro = _cqfu_peek(van, p_sut, way, tap);
          }
          else {
            pro = _cqfu_peek(van, q_sut, way, tap);
          }
          u3z(tap);
          u3z(tip);

          return pro;
        }
      }
      case c3__core: {
        u3_noun pq_sut, qq_sut, rq_sut;
        u3_noun prq_sut, qrq_sut;

        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ||
             (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
             (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) )
        {
          return u3m_bail(c3__fail);
        } else {
          u3_atom tip = u3qc_cap(axe);
          u3_atom tap = u3qc_mas(axe);

          if ( 3 == tip ) {
            if ( c3n == u3qfu_park(van, sut, way, tap) )
            {
              // u3_noun dun = u3qfu_dunq(van, "type", sut);
              u3_noun waz = u3qfu_shep
                (van, "axis", 'd', u3k(axe));

              // u3t_push(u3nc(c3__mean, dun));
              u3t_push(u3nc(c3__mean, waz));

              return u3m_error("peek-park");
            }
            else pro = _cqfu_peek(van, p_sut, way, tap);
          }
          else {
            pro = c3__noun;
          }
          u3z(tap);
          u3z(tip);

          return pro;
        }
      }
      case c3__cube: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__fork: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_noun hed = _peek_in(van, p_sut, way, axe, gil);
          u3_noun tal = _peek_in(van, q_sut, way, axe, gil);

          pro = u3qf_fork(hed, tal);

          u3z(hed);
          u3z(tal);

          return pro;
        }
      }
      case c3__hold: {
        p_sut = u3t(sut);
        if ( (c3y == u3qdi_has(gil, sut)) ) {
          return c3__void;
        }
        else {
          u3_noun zoc = u3qdi_put(gil, sut);
          u3_noun fop = u3qfu_repo(van, sut);
          u3_noun pro = _peek_in(van, fop, way, axe, zoc);

          u3z(fop);
          u3z(zoc);

          return pro;
        }
      }
    }
  }
Beispiel #9
0
  static u3_noun
  _peek_in(u3_noun van,
           u3_noun sut,
           u3_noun way,
           u3_atom axe,
           u3_noun gil)
  {
    u3_noun p_sut, q_sut;
    u3_noun pro;

    if ( (c3n == u3du(sut)) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: {
        return c3__noun;
      }
      case c3__void: {
        return c3__void;
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        return c3__void;
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_atom tip = u3qc_cap(axe);
          u3_atom tap = u3qc_mas(axe);

          if ( 2 == tip ) {
            pro = _cqfu_peek(van, p_sut, way, tap);
          }
          else {
            pro = _cqfu_peek(van, q_sut, way, tap);
          }
          u3z(tap);
          u3z(tip);

          return pro;
        }
      }
      case c3__core: {
        u3_noun pq_sut, qq_sut, rq_sut;
        u3_noun prq_sut, qrq_sut;

        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ||
             (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
             (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) )
        {
          return u3m_bail(c3__fail);
        } else {
          u3_atom now = u3qc_cap(axe);
          u3_atom lat = u3qc_mas(axe);

          if ( 3 == now ) {
            u3_noun pec = u3qfu_perk(van, sut, way, pq_sut);
            u3_noun sam = u3h(pec);
            u3_noun con = u3t(pec);

            if ( c3y == c3a(sam, con) ) {
              pro = _cqfu_peek(van, p_sut, way, lat);
            }
            else {
              u3_noun typ;

              {
                u3_noun hed, tal;

                if ( c3n == sam ) {
                  hed = c3__noun;
                } else {
                  hed = _cqfu_peek(van, p_sut, way, 2);
                }

                if ( c3n == con ) {
                  tal = c3__noun;
                } else {
                  tal = _cqfu_peek(van, p_sut, way, 3);
                }

                typ = u3qf_cell(hed, tal);
                u3z(hed);
                u3z(tal);
              }

              pro = _cqfu_peek(van, typ, way, lat);
              u3z(typ);
            }

            u3z(pec);
          }
          else {
            pro = c3__noun;
          }
          u3z(lat);
          u3z(now);

          return pro;
        }
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__fork: p_sut = u3t(sut);
      {
        u3_noun yed = u3qdi_tap(p_sut, u3_nul);
        u3_noun ret = u3kf_fork(_peek_fork(van, yed, way, axe, gil));

        u3z(yed);
        return ret;
      }
      case c3__hold: {
        if ( (c3y == u3qdi_has(gil, sut)) ) {
          return c3__void;
        }
        else {
          u3_noun zoc = u3qdi_put(gil, sut);
          u3_noun fop = u3qfu_repo(van, sut);
          u3_noun pro = _peek_in(van, fop, way, axe, zoc);

          u3z(fop);
          u3z(zoc);

          return pro;
        }
      }
    }
  }
Beispiel #10
0
  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;
  }