up

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

up_wane.c (826B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdu_wane(u3_noun k, u3_atom p, u3_noun v, u3_atom m, u3_noun l, u3_noun r)
      5 {
      6   if ( u3_nul == r ) {
      7     if  ( u3_nul == l) {
      8       return u3nq(c3__tip, u3k(k), u3k(p), u3k(v));
      9     }
     10     else {
     11       return u3nq(c3__bin, u3k(k), u3k(p),
     12                u3nq(u3k(v), u3k(m), u3k(l), u3_nul));
     13     }
     14   }
     15   else {
     16     return u3nq(c3__bin, u3k(k), u3k(p),
     17              u3nq(u3k(v), u3k(m), u3k(l), u3k(r)));
     18   }
     19 }
     20 
     21 u3_noun
     22 u3wdu_wane(u3_noun cor)
     23 {
     24   u3_noun k, p, v, m, l, r;
     25 
     26   if (
     27     (c3n == u3r_mean(cor, u3x_sam_2, &k, u3x_sam_6, &p, u3x_sam_14, &v,
     28                      u3x_sam_30, &m, u3x_sam_62, &l, u3x_sam_63, &r, 0 )) ||
     29     (c3n == u3ud(m)) ||
     30     (c3n == u3ud(p)) ||
     31     (c3n == u3du(v))
     32     )
     33   {
     34     return u3m_bail(c3__exit);
     35   } else {
     36     return u3qdu_wane(k, p, v, m, l, r);
     37   }
     38 }
     39