shrub/j/3/bex.c
2014-09-05 13:13:24 -07:00

40 lines
596 B
C

/* j/3/bex.c
**
** This file is in the public domain.
*/
#include "all.h"
/* functions
*/
u3_noun
u3_cqc_bex(u3_atom a)
{
mpz_t a_mp;
if ( u3_ne(u3_co_is_cat(a)) ) {
return u3_cm_bail(c3__fail);
}
else {
mpz_init_set_ui(a_mp, 1);
mpz_mul_2exp(a_mp, a_mp, a);
return u3_ci_mp(a_mp);
}
}
u3_noun
u3_cwc_bex(
u3_noun cor)
{
u3_noun a;
if ( (u3_none == (a = u3_cr_at(u3_cv_sam, cor))) ||
(u3_no == u3ud(a)) )
{
return u3_cm_bail(c3__exit);
} else {
return u3_cqc_bex(a);
}
}