up

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

up_funk.c (823B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdu_funk(u3_noun k, u3_atom p, u3_noun v, u3_atom m, u3_noun l, u3_noun r)
      5 {
      6   if ( u3_nul == l ) {
      7     if  ( u3_nul == r ) {
      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), u3_nul, u3k(r)));
     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_funk(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 == u3du(v)) ||
     31     (c3n == u3ud(p)) )
     32   {
     33     return u3m_bail(c3__exit);
     34   } else {
     35     return u3qdu_funk(k, p, v, m, l, r);
     36   }
     37 }
     38