up

A priority search queue and LRU cache.
git clone git://git.jtobin.io/up.git
Log | Files | Refs

up_qor_del.c (2339B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdu_qor_del(u3_noun a, u3_noun k)
      5 {
      6   if (u3_nul == a) {
      7     return u3_nul;
      8   }
      9 
     10   u3_noun n_a, t_a, m_a;
     11   u3x_trel(a, &n_a, &t_a, &m_a);
     12 
     13   if (u3_nul == t_a) {
     14     u3_noun kn_a = u3h(n_a);
     15 
     16     if (c3y == u3r_sing(k, kn_a)) {
     17       return u3_nul;
     18     }
     19     else {
     20       return u3nt(u3k(n_a), u3_nul, u3k(kn_a));
     21     }
     22   }
     23 
     24   u3_noun hot = u3h(t_a);
     25 
     26   if (c3n == u3ud(hot)) {
     27     return u3m_bail(c3__exit);
     28   }
     29   else switch ( hot ) {
     30     default:
     31       return u3m_bail(c3__exit);
     32 
     33     case c3__rlos: {
     34       u3_noun b = u3t(u3t(t_a));
     35 
     36       u3_noun n_b, l_b, m_b, r_b;
     37       u3x_qual(b, &n_b, &l_b, &m_b, &r_b);
     38 
     39       if ( (c3y == u3r_sing(k, m_b)) || (c3y == u3qc_gor(k, m_b)) ) {
     40         u3_noun lel = u3nt(u3k(n_a), u3k(l_b), u3k(m_b));
     41         u3_noun rel = u3nt(u3k(n_b), u3k(r_b), u3k(m_a));
     42 
     43         u3_noun lod = u3qdu_qor_del(lel, k);
     44         u3_noun pro = u3qdu_qor_toy(lod, rel);
     45 
     46         u3z(lod);
     47         u3z(lel);
     48         u3z(rel);
     49 
     50         return pro;
     51       }
     52       else {
     53         u3_noun lel = u3nt(u3k(n_a), u3k(l_b), u3k(m_b));
     54         u3_noun rel = u3nt(u3k(n_b), u3k(r_b), u3k(m_a));
     55 
     56         u3_noun rod = u3qdu_qor_del(rel, k);
     57         u3_noun pro = u3qdu_qor_toy(lel, rod);
     58 
     59         u3z(rod);
     60         u3z(lel);
     61         u3z(rel);
     62 
     63         return pro;
     64       }
     65     }
     66 
     67     case c3__llos: {
     68       u3_noun b = u3t(u3t(t_a));
     69 
     70       u3_noun n_b, l_b, m_b, r_b;
     71       u3x_qual(b, &n_b, &l_b, &m_b, &r_b);
     72 
     73       if ( (c3y == u3r_sing(k, m_b)) || (c3y == u3qc_gor(k, m_b)) ) {
     74         u3_noun lel = u3nt(u3k(n_b), u3k(l_b), u3k(m_b));
     75         u3_noun rel = u3nt(u3k(n_a), u3k(r_b), u3k(m_a));
     76 
     77         u3_noun lod = u3qdu_qor_del(lel, k);
     78         u3_noun pro = u3qdu_qor_toy(lod, rel);
     79 
     80         u3z(lod);
     81         u3z(lel);
     82         u3z(rel);
     83 
     84         return pro;
     85       }
     86       else {
     87         u3_noun lel = u3nt(u3k(n_b), u3k(l_b), u3k(m_b));
     88         u3_noun rel = u3nt(u3k(n_a), u3k(r_b), u3k(m_a));
     89 
     90         u3_noun rod = u3qdu_qor_del(rel, k);
     91         u3_noun pro = u3qdu_qor_toy(lel, rod);
     92 
     93         u3z(rod);
     94         u3z(lel);
     95         u3z(rel);
     96 
     97         return pro;
     98       }
     99     }
    100   }
    101 }
    102 
    103 u3_noun
    104 u3wdu_qor_del(u3_noun cor)
    105 {
    106   u3_noun a, k;
    107 
    108   if (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &k, 0))
    109   {
    110     return u3m_bail(c3__exit);
    111   } else {
    112     return u3qdu_qor_del(a, k);
    113   }
    114 }
    115 
    116 
    117