Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/jub: jet for jub:by #510

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pkg/noun/jets/d/by_gos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// @file

#include "jets/k.h"
#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"

u3_noun
u3qdb_gos(u3_noun a,
u3_noun b)
{
if ( u3_nul == b ) {
return u3k(a);
}
else {
u3_noun i_b, t_b,
pi_b, qi_b;
u3x_cell(b, &i_b, &t_b);
u3x_cell(i_b, &pi_b, &qi_b);

u3_noun c = u3qdb_pyt(a, pi_b, qi_b);
u3_noun d = u3qdb_gos(c, t_b);
u3z(c);
return d;
}
}

u3_noun
u3wdb_gos(u3_noun cor)
{
u3_noun a, b;
u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0);
return u3qdb_gos(a, b);
}

u3_noun
u3kdb_gos(u3_noun a,
u3_noun b)
{
u3_noun c = u3qdb_gos(a, b);
u3z(a); u3z(b);
return c;
}
129 changes: 129 additions & 0 deletions pkg/noun/jets/d/by_jub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* j/4/by_jub.c
**
*/
#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"

u3_noun
u3qdb_jub(u3_noun a,
u3_noun key,
u3_noun fun)
{
if ( u3_nul == a ) {
u3_noun val = u3n_slam_on(u3k(fun), u3_nul);

if ( u3_nul != val ) {
u3_noun b = u3nt(u3nc(u3k(key), u3k(u3t(val))), u3_nul, u3_nul);

u3z(val);
return b;
}
else {
return u3_nul;
}
}

else {
u3_noun n_a, lr_a;
u3_noun pn_a, qn_a;
u3x_cell(a, &n_a, &lr_a);
u3x_cell(n_a, &pn_a, &qn_a);

if ( c3y == u3r_sing(pn_a, key) ) {
u3_noun val = u3n_slam_on(u3k(fun), u3nc(u3_nul, u3k(qn_a)));

if ( u3_nul != val ) {
u3_noun u_val = u3t(val);

if ( c3y == u3r_sing(qn_a, u_val) ) {

u3z(val);
return u3k(a);
}
else {
u3_noun b = u3nc(u3nc(u3k(pn_a), u3k(u_val)), u3k(lr_a));

u3z(val);
return b;
}
}
else {
u3_noun b = u3qdb_del(a, key);

return b;
}
}
else {
u3_noun l_a, r_a;
u3x_cell(lr_a, &l_a, &r_a);
u3_noun d;

if ( c3y == u3qc_gor(key, pn_a) ) {
d = u3qdb_jub(l_a, key, fun);

if ( u3_nul == d ) {
return u3qdb_put(u3k(r_a), u3k(pn_a), u3k(qn_a));
}

if ( c3y == u3qc_mor(pn_a, u3h(u3h(d))) ) {
return u3nt(u3k(n_a),
d,
u3k(r_a));
}
else {
u3_noun n_d, l_d, r_d;

u3r_trel(d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
u3k(l_d),
u3nt(u3k(n_a),
u3k(r_d),
u3k(r_a)));

u3z(d);
return e;
}
}
else {
d = u3qdb_jub(r_a, key, fun);

if ( u3_nul == d ) {
return u3qdb_put(u3k(l_a), u3k(pn_a), u3k(qn_a));
}

if ( c3y == u3qc_mor(pn_a, u3h(u3h(d))) ) {
return u3nt(u3k(n_a),
u3k(l_a),
d);
}
else {
u3_noun n_d, l_d, r_d;
u3r_trel(d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
u3nt(u3k(n_a),
u3k(l_a),
u3k(l_d)),
u3k(r_d));

u3z(d);
return e;
}
}
}
}
}

u3_noun
u3wdb_jub(u3_noun cor)
{
u3_noun a, key, fun;
u3x_mean(cor, u3x_sam_2, &key,
u3x_sam_3, &fun,
u3x_con_sam, &a, 0);

return u3qdb_jub(a, key, fun);
}
4 changes: 3 additions & 1 deletion pkg/noun/jets/d/by_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ u3qdb_put(u3_noun a,
}
}
else {
u3_noun d, n_d, l_d, r_d;
u3_noun d;

if ( c3y == u3qc_gor(b, pn_a) ) {
d = u3qdb_put(l_a, b, c);
Expand All @@ -44,6 +44,7 @@ u3qdb_put(u3_noun a,
u3k(r_a));
}
else {
u3_noun n_d, l_d, r_d;
u3r_trel(d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
Expand All @@ -65,6 +66,7 @@ u3qdb_put(u3_noun a,
d);
}
else {
u3_noun n_d, l_d, r_d;
u3r_trel(d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
Expand Down
135 changes: 135 additions & 0 deletions pkg/noun/jets/d/by_pyt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/// @file

#include "jets/k.h"
#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"

typedef struct {
c3_o mut;
u3_noun d;
} pyt_inner_ret;

pyt_inner_ret
u3qdb_pyt_inner(u3_noun a,
u3_noun b,
u3_noun c)
{
if ( u3_nul == a ) {
return ( pyt_inner_ret ) { c3y, u3nt(u3nc(u3k(b), u3k(c)),
u3_nul,
u3_nul) };
}
else {
u3_noun n_a, l_a, r_a;
u3_noun pn_a, qn_a;
u3x_trel(a, &n_a, &l_a, &r_a);
u3x_cell(n_a, &pn_a, &qn_a);

if ( c3y == u3r_sing(pn_a, b) ) {
if ( c3y == u3r_sing(qn_a, c) ) {
return ( pyt_inner_ret ) { c3n, u3_nul } ;
}
else {
return ( pyt_inner_ret ) { c3y, u3nt(u3nc(u3k(b), u3k(c)),
u3k(l_a),
u3k(r_a))};
}
}
else {
pyt_inner_ret d_ret;

if ( c3y == u3qc_gor(b, pn_a) ) {
d_ret = u3qdb_pyt_inner(l_a, b, c);

if ( c3n == d_ret.mut ) {
return d_ret;
}

if ( c3y == u3qc_mor(pn_a, u3h(u3h(d_ret.d))) ) {
d_ret.d = u3nt(u3k(n_a),
d_ret.d,
u3k(r_a));
return d_ret;
}
else {
u3_noun n_d, l_d, r_d;
u3r_trel(d_ret.d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
u3k(l_d),
u3nt(u3k(n_a),
u3k(r_d),
u3k(r_a)));

u3z(d_ret.d);
d_ret.d = e;
return d_ret;
}
}
else {
d_ret = u3qdb_pyt_inner(r_a, b, c);

if ( c3n == d_ret.mut ) {
return d_ret;
}

if ( c3y == u3qc_mor(pn_a, u3h(u3h(d_ret.d))) ) {
d_ret.d = u3nt(u3k(n_a),
u3k(l_a),
d_ret.d);
return d_ret;
}
else {
u3_noun n_d, l_d, r_d;
u3r_trel(d_ret.d, &n_d, &l_d, &r_d);

u3_noun e = u3nt(u3k(n_d),
u3nt(u3k(n_a),
u3k(l_a),
u3k(l_d)),
u3k(r_d));

u3z(d_ret.d);
d_ret.d = e;
return d_ret;
}
}
}
}
}

u3_noun
u3qdb_pyt(u3_noun a,
u3_noun b,
u3_noun c)
{
pyt_inner_ret d_ret = u3qdb_pyt_inner(u3k(a), b, c);
if ( c3y == d_ret.mut ) {
u3z(a);
return d_ret.d;
}
return a;
}


u3_noun
u3wdb_pyt(u3_noun cor)
{
u3_noun a, b, c;
u3x_mean(cor, u3x_sam_2, &b,
u3x_sam_3, &c,
u3x_con_sam, &a, 0);
return u3qdb_pyt(a, b, c);
}

u3_noun
u3kdb_pyt(u3_noun a,
u3_noun b,
u3_noun c)
{
u3_noun pro = u3qdb_pyt(a, b, c);
u3z(a); u3z(b); u3z(c);
return pro;
}
2 changes: 2 additions & 0 deletions pkg/noun/jets/q.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@
u3_noun u3qdb_dif(u3_noun, u3_noun);
u3_noun u3qdb_gas(u3_noun, u3_noun);
u3_noun u3qdb_get(u3_noun, u3_noun);
u3_noun u3qdb_del(u3_noun, u3_noun);
u3_noun u3qdb_has(u3_noun, u3_noun);
u3_noun u3qdb_int(u3_noun, u3_noun);
u3_noun u3qdb_key(u3_noun);
u3_noun u3qdb_put(u3_noun, u3_noun, u3_noun);
u3_noun u3qdb_pyt(u3_noun, u3_noun, u3_noun);
u3_noun u3qdb_run(u3_noun, u3_noun);
# define u3qdb_tap u3qdi_tap
u3_noun u3qdb_uni(u3_noun, u3_noun);
Expand Down
Loading