Beispiel #1
0
/* 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;
      }
    }
  }
Beispiel #2
0
  static u3_noun
  _nest_cong(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;
    u3_noun pq_sut, qq_sut, rq_sut;
    u3_noun pq_ref, qq_ref, rq_ref;
    u3_noun prq_sut, qrq_sut, prq_ref, qrq_ref;
    u3_noun ret;

    u3x_trel(sut, 0, &p_sut, &q_sut);
    u3x_trel(ref, 0, &p_ref, &q_ref);

    u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut);
    u3x_trel(q_ref, &pq_ref, &qq_ref, &rq_ref);

    u3x_cell(rq_sut, &prq_sut, &qrq_sut);
    u3x_cell(rq_ref, &prq_ref, &qrq_ref);

    if ( c3y == u3r_sing(q_sut, q_ref) ) {
      return _nest_dext(van, p_sut, tel, p_ref, gil);
    }
    else if ( (c3n == _nest_dext(van, qq_sut, tel, p_sut, gil)) ||
              (c3n == _nest_dext(van, p_sut, tel, qq_sut, gil)) ||
              (c3n == _nest_dext(van, qq_ref, tel, p_ref, gil)) )
    {
      return c3n;
    }
    else {
      if ( (pq_sut != pq_ref) && (c3__gold != pq_ref) ) {
        return c3n;
      }
      else {
        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 tus = u3nt(c3__core,
                                     u3k(qq_sut),
                                     u3k(q_sut));
          u3_noun fer = u3nt(c3__core,
                                     u3k(qq_ref),
                                     u3k(q_ref));

          ret = _nest_cram(van, tus, tel, fer, qrq_sut, qrq_ref, zoc);
          u3z(fer);
          u3z(tus);
          u3z(zoc);
          u3z(hud);

          if ( c3n == ret ) {
            return c3n;
          }
          else {
            switch ( pq_sut ) {
              default: return u3m_bail(c3__fail);

              case c3__gold: {
                return
                  c3a(_nest_dext(van, qq_sut, tel, qq_ref, gil),
                         _nest_dext(van, qq_ref, tel, qq_sut, gil));
              }
              case c3__iron: {
                u3_noun s_sam = u3qfu_peek
                                        (van, qq_sut, c3__rite, 2);
                u3_noun r_sam = u3qfu_peek
                                        (van, qq_ref, c3__rite, 2);
                u3_noun ret = _nest_dext(van, r_sam, tel, s_sam, gil);

                u3z(r_sam);
                u3z(s_sam);
                return ret;
              }
              case c3__lead: {
                return c3y;
              }
              case c3__zinc: {
                u3_noun s_pal = u3qfu_peek
                                        (van, qq_sut, c3__read, 2);
                u3_noun r_pal = u3qfu_peek
                                        (van, qq_ref, c3__read, 2);
                u3_noun ret = _nest_dext(van, s_pal, tel, r_pal, gil);

                u3z(r_pal);
                u3z(s_pal);

                return ret;
              }
            }
          }
        }
      }
    }
  }