urbit/noun/xtract.c

91 lines
1.3 KiB
C
Raw Normal View History

2014-09-11 04:01:32 +04:00
/* g/x.c
2014-09-05 23:55:16 +04:00
**
*/
#include "all.h"
2014-11-06 03:20:01 +03:00
/* u3x_good(): test for u3_none.
2014-09-05 23:55:16 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_good(u3_weak som)
2014-09-05 23:55:16 +04:00
{
2014-11-06 02:36:30 +03:00
if ( u3_none == som ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2014-09-05 23:55:16 +04:00
}
else return som;
}
2014-11-06 03:20:01 +03:00
/* u3x_at (u3at): fragment.
2014-09-05 23:55:16 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_at(u3_noun axe, u3_noun som)
2014-09-05 23:55:16 +04:00
{
2014-11-06 03:20:01 +03:00
u3_weak pro = u3r_at(axe, som);
2014-09-05 23:55:16 +04:00
2014-11-06 02:36:30 +03:00
if ( u3_none == pro ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2014-09-05 23:55:16 +04:00
} else return pro;
}
2014-11-06 03:20:01 +03:00
/* u3x_cell():
2014-09-05 23:55:16 +04:00
**
** Divide `a` as a cell `[b c]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_cell(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c)
2014-09-05 23:55:16 +04:00
{
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_cell(a, b, c) ) {
u3m_bail(c3__exit);
2014-09-05 23:55:16 +04:00
}
}
2014-11-06 03:20:01 +03:00
/* u3x_trel():
2014-09-05 23:55:16 +04:00
**
** Divide `a` as a trel `[b c d]`, or bail.
*/
void
2014-11-06 03:20:01 +03:00
u3x_trel(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d)
2014-09-05 23:55:16 +04:00
{
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_trel(a, b, c, d) ) {
u3m_bail(c3__exit);
2014-09-05 23:55:16 +04:00
}
}
2014-11-06 03:20:01 +03:00
/* u3x_qual():
2014-09-05 23:55:16 +04:00
**
** Divide `a` as a quadruple `[b c d e]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_qual(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d,
u3_noun* e)
2014-09-05 23:55:16 +04:00
{
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_qual(a, b, c, d, e) ) {
u3m_bail(c3__exit);
2014-09-05 23:55:16 +04:00
}
}
2014-10-22 00:53:27 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_quil():
2014-10-22 00:53:27 +04:00
**
** Divide `a` as a quintuple `[b c d e f]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_quil(u3_noun a,
2014-10-22 00:53:27 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d,
u3_noun* e,
u3_noun* f)
{
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_quil(a, b, c, d, e, f) ) {
u3m_bail(c3__exit);
2014-10-22 00:53:27 +04:00
}
}