diff --git a/include/c/motes.h b/include/c/motes.h index 987c4845fa..b39a60a888 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -396,6 +396,7 @@ # define c3__flot c3_s4('f','l','o','t') # define c3__flow c3_s4('f','l','o','w') # define c3__fon c3_s3('f','o','n') +# define c3__fond c3_s4('f','o','n','d') # define c3__for c3_s3('f','o','r') # define c3__forb c3_s4('f','o','r','b') # define c3__fore c3_s4('f','o','r','e') diff --git a/include/jets/q.h b/include/jets/q.h index cd27630080..96b954fd00 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -203,7 +203,7 @@ u3_noun u3qfu_dung(u3_noun, u3_noun cap, u3_noun); u3_noun u3qfu_dunq(u3_noun, const c3_c*, u3_noun); void u3qfu_dump(u3_noun, const c3_c*, u3_noun); - u3_noun u3qfu_find(u3_noun, u3_noun, u3_noun, u3_noun); + u3_noun u3qfu_fond(u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3qfu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3qfu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3qfu_fire(u3_noun, u3_noun, u3_noun); diff --git a/include/jets/w.h b/include/jets/w.h index f968c9086a..b4d24134b1 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -221,6 +221,7 @@ u3_noun u3wfu_cull(u3_noun); u3_noun u3wfu_duck(u3_noun); u3_noun u3wfu_find(u3_noun); + u3_noun u3wfu_fond(u3_noun); u3_noun u3wfu_fink(u3_noun); u3_noun u3wfu_fire(u3_noun); u3_noun u3wfu_firm(u3_noun); diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index aeda561fb7..8b2f45e850 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -41,6 +41,37 @@ 0)); } + static u3_noun + u3qfu_funk(u3_noun van, + u3_noun sut, + u3_noun tor) + { + u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); + u3_noun gat = u3j_hook(von, "funk"); + + return u3n_kick_on(u3i_molt(gat, + u3x_sam, + u3k(tor), + 0)); + } + + static u3_noun + u3qfu_fund(u3_noun van, + u3_noun sut, + u3_noun way, + u3_noun hyp) + { + u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); + u3_noun gat = u3j_hook(von, "fund"); + + return u3n_kick_on(u3i_molt(gat, + u3x_sam_2, + u3k(way), + u3x_sam_3, + u3k(hyp), + 0)); + } + static u3_noun u3qfu_perk(u3_noun van, u3_noun sut, @@ -686,6 +717,33 @@ } } + extern void + u3_lo_tank(c3_l tab_l, u3_noun tac); + + static u3_noun + _cqfu_fond(u3_noun van, + u3_noun sut, + u3_noun way, + u3_noun hyp) + { + u3_noun old = u3qfu_fund(van, sut, way, hyp); + u3_noun new = _find_pony(van, sut, way, hyp); + + if ( c3n == u3r_sing(old, new) ) { + u3_noun olf = u3qfu_funk(van, sut, old); + u3_noun nef = u3qfu_funk(van, sut, new); + + u3qfu_dump(van, "sut", sut); + u3qfu_dump(van, "hyp", hyp); + + fprintf(stderr, "old:\r\n"); + u3_lo_tank(1, olf); + fprintf(stderr, "new:\r\n"); + u3_lo_tank(1, nef); + } + return _find_pony(van, sut, way, hyp); + } + u3_noun _cqfu_find(u3_noun van, u3_noun sut, @@ -757,3 +815,41 @@ return u3z_save_3(fun_m, sut, way, hyp, pro); } } + +/* boilerplate +*/ + u3_noun + u3wfu_fond(u3_noun cor) + { + u3_noun sut, way, hyp, van; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, + u3x_sam_3, &hyp, + u3x_con, &van, + 0)) || + (u3_none == (sut = u3r_at(u3x_sam, van))) ) + { + return u3m_bail(c3__fail); + } else { + return _cqfu_fond(van, sut, way, hyp); + } + } + + u3_noun + u3qfu_fond(u3_noun van, + u3_noun sut, + u3_noun way, + u3_noun hyp) + { + c3_m fun_m = c3__fond + !!u3r_at(u3qfu_van_vet, van); + u3_noun pro = u3z_find_3(fun_m, sut, way, hyp); + + if ( u3_none != pro ) { + return pro; + } + else { + pro = _cqfu_fond(van, sut, way, hyp); + + return u3z_save_3(fun_m, sut, way, hyp, pro); + } + } diff --git a/jets/tree.c b/jets/tree.c index 9f6f1e8277..3abea9b426 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -348,7 +348,7 @@ static u3j_harm _mood__hoon__ut_burn_a[] = {{".2", u3wfu_burn}, {}}; static u3j_harm _mood__hoon__ut_conk_a[] = {{".2", u3wfu_conk}, {}}; static u3j_harm _mood__hoon__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; // static u3j_harm _mood__hoon__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; -static u3j_harm _mood__hoon__ut_find_a[] = {{".2", u3wfu_find, c3n}, {}}; +// static u3j_harm _mood__hoon__ut_fond_a[] = {{".2", u3wfu_fond, c3n}, {}}; static u3j_harm _mood__hoon__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; static u3j_harm _mood__hoon__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; static u3j_harm _mood__hoon__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; @@ -366,7 +366,7 @@ static u3j_core _mood__hoon__ut_d[] = { "burn", _mood__hoon__ut_burn_a }, { "conk", _mood__hoon__ut_conk_a }, { "crop", _mood__hoon__ut_crop_a }, - { "find", _mood__hoon__ut_find_a }, + { "fond", _mood__hoon__ut_fond_a }, // { "fire", _mood__hoon__ut_fire_a }, { "fish", _mood__hoon__ut_fish_a }, { "fuse", _mood__hoon__ut_fuse_a }, diff --git a/noun/jets.c b/noun/jets.c index 05819f5f39..87dc22798d 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -402,7 +402,7 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) (!strcmp(".2", ham_u->fcs_c)) ? "$" : ham_u->fcs_c, u3r_mug(ame), u3r_mug(pro)); - + c3_assert(0); return u3m_bail(c3__fail); }