up

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

up_feud.c (728B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 _mask(u3_atom a)
      5 {
      6   u3_atom x = u3qa_dec(a);
      7   u3_atom y = u3qc_mix(x, 0x7fffffff);
      8 
      9   u3_atom pro = u3qc_mix(y, a);
     10 
     11   u3z(x);
     12   u3z(y);
     13 
     14   return pro;
     15 }
     16 
     17 c3_o
     18 u3qdu_feud(u3_atom m, u3_atom k, u3_atom l)
     19 {
     20   u3_atom n = _mask(m);
     21   u3_atom h = u3r_mug(k);
     22   u3_atom i = u3r_mug(l);
     23   u3_atom a = u3qc_dis(h, n);
     24   u3_atom b = u3qc_dis(i, n);
     25 
     26   u3_atom pro = ( a == b ) ? c3n : c3y;
     27 
     28   u3z(n);
     29   u3z(h);
     30   u3z(i);
     31   u3z(a);
     32   u3z(b);
     33 
     34   return pro;
     35 }
     36 
     37 u3_noun
     38 u3wdu_feud(u3_noun cor)
     39 {
     40   u3_noun m, k, l;
     41 
     42   if (
     43     (c3n == u3r_mean(cor, u3x_sam_2, &m, u3x_sam_6, &k, u3x_sam_7, &l, 0 )) ||
     44     (c3n == u3ud(m)) )
     45   {
     46     return u3m_bail(c3__exit);
     47   } else {
     48     return u3qdu_feud(m, k, l);
     49   }
     50 }
     51