diff --git a/Makefile b/Makefile index 9ec9c5758d..73f9efd661 100644 --- a/Makefile +++ b/Makefile @@ -150,6 +150,7 @@ J_B_OFILES=\ jets/b/lien.o \ jets/b/murn.o \ jets/b/need.o \ + jets/b/reap.o \ jets/b/reel.o \ jets/b/roll.o \ jets/b/skim.o \ diff --git a/include/jets/q.h b/include/jets/q.h index 22c64d725b..b5666e8678 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -27,6 +27,7 @@ u3_noun u3qb_lien(u3_noun, u3_noun); u3_noun u3qb_murn(u3_noun, u3_noun); u3_noun u3qb_need(u3_noun); + u3_noun u3qb_reap(u3_atom, u3_noun); u3_noun u3qb_reel(u3_noun, u3_noun); u3_noun u3qb_roll(u3_noun, u3_noun); u3_noun u3qb_skim(u3_noun, u3_noun); diff --git a/include/jets/w.h b/include/jets/w.h index 70e54bd39b..fc4ea47488 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -26,6 +26,7 @@ u3_noun u3wb_lien(u3_noun); u3_noun u3wb_murn(u3_noun); u3_noun u3wb_need(u3_noun); + u3_noun u3wb_reap(u3_noun); u3_noun u3wb_reel(u3_noun); u3_noun u3wb_roll(u3_noun); u3_noun u3wb_skim(u3_noun); diff --git a/jets/b/reap.c b/jets/b/reap.c new file mode 100644 index 0000000000..87a7d7809f --- /dev/null +++ b/jets/b/reap.c @@ -0,0 +1,41 @@ +/* j/2/reap.c +** +*/ +#include "all.h" + + +/* functions +*/ + u3_noun + u3qb_reap(u3_atom a, + u3_noun b) + { + if ( !_(u3a_is_cat(a)) ) { + return u3m_bail(c3__fail); + } + else { + u3_noun acc = u3_nul; + c3_w i_w = a; + + while ( i_w ) { + acc = u3nc(b, acc); + i_w--; + } + + return acc; + } + } + + u3_noun + u3wb_reap(u3_noun cor) + { + u3_noun a, b; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || + (c3n == u3ud(a)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qb_reap(a, b); + } + } diff --git a/jets/tree.c b/jets/tree.c index f87f1acf52..c7094b4c80 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -23,6 +23,7 @@ static u3j_harm _mood__hoon_levy_a[] = {{".2", u3wb_levy, c3y}, {}}; static u3j_harm _mood__hoon_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; static u3j_harm _mood__hoon_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; static u3j_harm _mood__hoon_need_a[] = {{".2", u3wb_need, c3y}, {}}; +static u3j_harm _mood__hoon_reap_a[] = {{".2", u3wb_reap, c3y}, {}}; static u3j_harm _mood__hoon_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; static u3j_harm _mood__hoon_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; static u3j_harm _mood__hoon_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; @@ -454,6 +455,7 @@ static u3j_core _mood__hoon_d[] = { "lien", _mood__hoon_lien_a }, { "murn", _mood__hoon_murn_a }, { "need", _mood__hoon_need_a }, + { "reap", _mood__hoon_reap_a }, { "reel", _mood__hoon_reel_a }, { "roll", _mood__hoon_roll_a }, { "skim", _mood__hoon_skim_a },