up

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

up_rule.c (716B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdu_rule(u3_atom k, u3_atom p, u3_noun v, u3_noun a, u3_noun b)
      5 {
      6   u3_atom l = u3h(u3t(a));
      7   u3_atom m = u3qdu_peak(k, l);
      8 
      9   return (c3y == u3qdu_zero(m, l))
     10        ? u3nq(c3__bin, u3k(k), u3k(p), u3nq(u3k(v), m, u3k(a), u3k(b)))
     11        : u3nq(c3__bin, u3k(k), u3k(p), u3nq(u3k(v), m, u3k(b), u3k(a)));
     12 }
     13 
     14 u3_noun
     15 u3wdu_rule(u3_noun cor)
     16 {
     17   u3_atom k, p;
     18   u3_noun v, a, b;
     19 
     20   if ( (c3n == u3r_mean(cor, u3x_sam_2, &k, u3x_sam_6, &p, u3x_sam_14, &v,
     21                       u3x_sam_30, &a, u3x_sam_31, &b, 0)) ||
     22        (c3n == u3ud(p)) ||
     23        (c3n == u3du(v)) ||
     24        (c3n == u3du(a)) )
     25   {
     26     return u3m_bail(c3__exit);
     27   } else {
     28     return u3qdu_rule(k, p, v, a, b);
     29   }
     30 }
     31 
     32 
     33