diff --git a/Makefile b/Makefile index bffa4f12e6..83ea4eb0ef 100644 --- a/Makefile +++ b/Makefile @@ -262,6 +262,7 @@ J_E_OFILES=\ jets/e/shax.o \ jets/e/lore.o \ jets/e/loss.o \ + jets/e/lune.o \ jets/e/trip.o J_E_OFILES_ED=\ diff --git a/include/jets/q.h b/include/jets/q.h index 96b954fd00..d508712eac 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -97,6 +97,7 @@ u3_noun u3qe_rub(u3_atom, u3_atom); u3_noun u3qe_lore(u3_atom); u3_noun u3qe_loss(u3_noun, u3_noun); + u3_noun u3qe_lune(u3_atom); u3_noun u3qe_repg(u3_noun, u3_noun, u3_noun); u3_noun u3qe_rexp(u3_noun, u3_noun); u3_noun u3qe_trip(u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index b4d24134b1..ebe70213f6 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -102,6 +102,7 @@ u3_noun u3we_rub(u3_noun); u3_noun u3we_lore(u3_noun); u3_noun u3we_loss(u3_noun); + u3_noun u3we_lune(u3_noun); u3_noun u3we_mink(u3_noun); u3_noun u3we_mule(u3_noun); u3_noun u3we_repg(u3_noun); diff --git a/jets/e/lune.c b/jets/e/lune.c new file mode 100644 index 0000000000..d8c8404ca4 --- /dev/null +++ b/jets/e/lune.c @@ -0,0 +1,47 @@ +/* j/5/lune.c +** +*/ +#include "all.h" + + + u3_noun + u3qe_lune(u3_atom lub) + { + if (lub == 0) { + return u3_nul; + } + + { + c3_w end_w = u3r_met(3, lub) - 1; + c3_w pos_w = end_w; + u3_noun lin = u3_nul; + + if (u3r_byte(pos_w, lub) != 10) { + return u3m_error("noeol"); + } + + while (--pos_w) { + if (u3r_byte(pos_w, lub) == 10) { + lin = u3nc(u3qc_cut(3, (pos_w + 1), (end_w - pos_w - 1), lub), lin); + end_w = pos_w; + continue; + } + } + + return u3nc(u3qc_cut(3, pos_w, (end_w - pos_w), lub), lin); + } + } + + u3_noun + u3we_lune(u3_noun cor) + { + u3_noun lub; + + if ( (u3_none == (lub = u3r_at(u3x_sam, cor))) || + (c3n == u3ud(lub)) ) + { + return u3m_bail(c3__fail); + } else { + return u3qe_lune(lub); + } + } diff --git a/jets/tree.c b/jets/tree.c index 180b30dae9..1f9bc6b96f 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -124,6 +124,7 @@ static u3j_harm _mood__hoon_mat_a[] = {{".2", u3we_mat}, {}}; static u3j_harm _mood__hoon_rub_a[] = {{".2", u3we_rub}, {}}; static u3j_harm _mood__hoon_lore_a[] = {{".2", u3we_lore}, {}}; static u3j_harm _mood__hoon_loss_a[] = {{".2", u3we_loss}, {}}; +static u3j_harm _mood__hoon_lune_a[] = {{".2", u3we_lune}, {}}; static u3j_harm _mood__hoon_mink_a[] = {{".2", u3we_mink}, {}}; static u3j_harm _mood__hoon_mule_a[] = {{".2", u3we_mule}, {}}; static u3j_harm _mood__hoon_repg_a[] = {{".2", u3we_repg}, {}}; @@ -484,6 +485,7 @@ static u3j_core _mood__hoon_d[] = { "rub", _mood__hoon_rub_a }, { "lore", _mood__hoon_lore_a }, { "loss", _mood__hoon_loss_a }, + { "lune", _mood__hoon_lune_a }, { "mink", _mood__hoon_mink_a }, { "mule", _mood__hoon_mule_a }, { "repg", _mood__hoon_repg_a },