mirror of
https://github.com/urbit/shrub.git
synced 2024-12-16 14:58:25 +03:00
Implement jet for ++rev.
This commit is contained in:
parent
b8712677ea
commit
919780c570
@ -43,6 +43,11 @@
|
|||||||
u3_noun
|
u3_noun
|
||||||
u3kc_rip(u3_atom a, u3_atom b);
|
u3kc_rip(u3_atom a, u3_atom b);
|
||||||
|
|
||||||
|
/* u3kc_rev(): reverse block order, accounting for leading zeroes.
|
||||||
|
*/
|
||||||
|
u3_noun
|
||||||
|
u3kc_rev(u3_atom boz, u3_atom len, u3_atom dat);
|
||||||
|
|
||||||
/* u3kc_swp(): reverse block order.
|
/* u3kc_swp(): reverse block order.
|
||||||
*/
|
*/
|
||||||
u3_noun
|
u3_noun
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
u3_noun u3qc_pow(u3_atom, u3_atom);
|
u3_noun u3qc_pow(u3_atom, u3_atom);
|
||||||
u3_noun u3qc_rap(u3_atom, u3_noun);
|
u3_noun u3qc_rap(u3_atom, u3_noun);
|
||||||
u3_noun u3qc_rep(u3_atom, u3_noun);
|
u3_noun u3qc_rep(u3_atom, u3_noun);
|
||||||
|
u3_noun u3qc_rev(u3_atom, u3_atom, u3_atom);
|
||||||
u3_noun u3qc_rip(u3_atom, u3_atom);
|
u3_noun u3qc_rip(u3_atom, u3_atom);
|
||||||
u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom);
|
u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom);
|
||||||
u3_noun u3qc_swp(u3_atom, u3_atom);
|
u3_noun u3qc_swp(u3_atom, u3_atom);
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
u3_noun u3wc_pow(u3_noun);
|
u3_noun u3wc_pow(u3_noun);
|
||||||
u3_noun u3wc_rap(u3_noun);
|
u3_noun u3wc_rap(u3_noun);
|
||||||
u3_noun u3wc_rep(u3_noun);
|
u3_noun u3wc_rep(u3_noun);
|
||||||
|
u3_noun u3wc_rev(u3_noun);
|
||||||
u3_noun u3wc_rip(u3_noun);
|
u3_noun u3wc_rip(u3_noun);
|
||||||
u3_noun u3wc_rsh(u3_noun);
|
u3_noun u3wc_rsh(u3_noun);
|
||||||
u3_noun u3wc_swp(u3_noun);
|
u3_noun u3wc_swp(u3_noun);
|
||||||
|
50
jets/c/rev.c
Normal file
50
jets/c/rev.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* j/3/rev.c
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
#include "all.h"
|
||||||
|
|
||||||
|
/* functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3qc_rev(u3_atom boz,
|
||||||
|
u3_atom len,
|
||||||
|
u3_atom dat)
|
||||||
|
{
|
||||||
|
if ( !_(u3a_is_cat(boz)) || (boz >= 32) ||
|
||||||
|
!_(u3a_is_cat(len)) ) {
|
||||||
|
return u3m_bail(c3__fail);
|
||||||
|
}
|
||||||
|
|
||||||
|
dat = u3qc_end(boz, len, dat);
|
||||||
|
c3_w met = u3r_met(boz, dat);
|
||||||
|
return u3kc_lsh(u3k(boz), (len - met), u3kc_swp(u3k(boz), dat));
|
||||||
|
}
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3wc_rev(u3_noun cor)
|
||||||
|
{
|
||||||
|
u3_noun boz, len, dat;
|
||||||
|
|
||||||
|
if ( (c3n == u3r_mean(cor, u3x_sam_2, &boz,
|
||||||
|
u3x_sam_6, &len,
|
||||||
|
u3x_sam_7, &dat, 0)) ||
|
||||||
|
(c3n == u3ud(boz)) ||
|
||||||
|
(c3n == u3ud(len)) ||
|
||||||
|
(c3n == u3ud(dat)) )
|
||||||
|
{
|
||||||
|
return u3m_bail(c3__exit);
|
||||||
|
} else {
|
||||||
|
return u3qc_rev(boz, len, dat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u3_noun
|
||||||
|
u3kc_rev(u3_atom boz,
|
||||||
|
u3_atom len,
|
||||||
|
u3_atom dat)
|
||||||
|
{
|
||||||
|
u3_noun res = u3qc_rev(boz, len, dat);
|
||||||
|
u3z(boz); u3z(len); u3z(dat);
|
||||||
|
return res;
|
||||||
|
}
|
@ -510,6 +510,7 @@ static u3j_core _143_tri_d[] =
|
|||||||
static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}};
|
static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}};
|
||||||
static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}};
|
static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}};
|
||||||
static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}};
|
static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}};
|
||||||
|
static u3j_harm _143_two_rev_a[] = {{".2", u3wc_rev, c3y}, {}};
|
||||||
static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}};
|
static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}};
|
||||||
static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}};
|
static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}};
|
||||||
static u3j_harm _143_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}};
|
static u3j_harm _143_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}};
|
||||||
@ -614,6 +615,7 @@ static u3j_core _143_two_d[] =
|
|||||||
{ "muk", _143_two_muk_a },
|
{ "muk", _143_two_muk_a },
|
||||||
{ "rap", _143_two_rap_a },
|
{ "rap", _143_two_rap_a },
|
||||||
{ "rep", _143_two_rep_a },
|
{ "rep", _143_two_rep_a },
|
||||||
|
{ "rev", _143_two_rev_a },
|
||||||
{ "rip", _143_two_rip_a },
|
{ "rip", _143_two_rip_a },
|
||||||
{ "rsh", _143_two_rsh_a },
|
{ "rsh", _143_two_rsh_a },
|
||||||
{ "rub", _143_two_rub_a },
|
{ "rub", _143_two_rub_a },
|
||||||
|
@ -71,6 +71,7 @@ jets_c_src = [
|
|||||||
'jets/c/pow.c',
|
'jets/c/pow.c',
|
||||||
'jets/c/rap.c',
|
'jets/c/rap.c',
|
||||||
'jets/c/rep.c',
|
'jets/c/rep.c',
|
||||||
|
'jets/c/rev.c',
|
||||||
'jets/c/rip.c',
|
'jets/c/rip.c',
|
||||||
'jets/c/rsh.c',
|
'jets/c/rsh.c',
|
||||||
'jets/c/swp.c',
|
'jets/c/swp.c',
|
||||||
|
Loading…
Reference in New Issue
Block a user