urbit/j/6/flip.c
2014-11-05 16:20:01 -08:00

44 lines
716 B
C

/* j/6/flip.c
**
** This file is in the public domain.
*/
#include "all.h"
/* functions
*/
u3_noun
u3_cqf_flip(
u3_noun hel)
{
if ( c3y == u3r_sing(1, u3h(hel)) ) {
if ( (c3y == u3t(hel)) ) {
return u3nc(1, c3n);
}
else {
c3_assert((c3n == u3t(hel)));
return u3nc(1, c3y);
}
}
else {
return u3nq
(6,
u3k(hel),
u3nc(1, c3n),
u3nc(1, c3y));
}
}
u3_noun
u3_cwf_flip(
u3_noun cor)
{
u3_noun hel;
if ( u3_none == (hel = u3r_at(u3v_sam, cor)) ) {
return u3m_bail(c3__fail);
} else {
return u3_cqf_flip(hel);
}
}