summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/jets/f/flip.c
blob: 9eb922e5e1919441cf259eb8c602547c62f1494e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/// @file

#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"


  u3_noun
  u3qf_flip(u3_noun hel)
  {
    if ( c3y == u3r_sing(1, u3h(hel)) ) {
      if ( (c3y == u3t(hel)) ) {
        return u3nc(1, c3n);
      }
      else {
        u3_assert((c3n == u3t(hel)));

        return u3nc(1, c3y);
      }
    }
    else {
      return u3nq(6,
                  u3k(hel),
                  u3nc(1, c3n),
                  u3nc(1, c3y));
    }
  }
  u3_noun
  u3wf_flip_139(u3_noun cor)
  {
    u3_noun hel;

    if ( u3_none == (hel = u3r_at(u3x_sam, cor)) ) {
      return u3m_bail(c3__fail);
    } else {
      return u3qf_flip(hel);
    }
  }