u3: implements u3i_list()/u3nl() varargs list constructor

This commit is contained in:
Joe Bryan 2020-06-06 01:54:33 -07:00
parent 406a823ddd
commit e7eceba965
3 changed files with 39 additions and 4 deletions

View File

@ -84,6 +84,11 @@
# define u3nt(a, b, c) u3i_trel(a, b, c)
# define u3nq(a, b, c, d) u3i_qual(a, b, c, d)
/* u3nl(), u3_none-terminated varargs list
*/
# define u3nl u3i_list
/* u3du(), u3ud(): noun/cell test.
*/
# define u3du(som) (u3r_du(som))

View File

@ -57,6 +57,11 @@
u3_atom
u3i_tape(const c3_c* txt_c);
/* u3i_list(): list from `u3_none`-terminated varargs.
*/
u3_noun
u3i_list(u3_weak som, ...);
/* u3i_edit():
**
** Mutate `big` at axis `axe` with new value `som`

View File

@ -301,13 +301,38 @@ u3i_tape(const c3_c* txt_c)
} else return u3i_cell(*txt_c, u3i_tape(txt_c + 1));
}
/* u3i_list():
**
** Generate a null-terminated list, with `u3_none` as terminator.
/* u3i_list(): list from `u3_none`-terminated varargs.
*/
u3_noun
u3i_list(u3_weak one, ...);
u3i_list(u3_weak som, ...)
{
u3_noun lit = u3_nul;
va_list ap;
if ( u3_none == som ) {
return lit;
}
else {
lit = u3nc(som, lit);
}
{
u3_noun tem;
va_start(ap, som);
while ( 1 ) {
if ( u3_none == (tem = va_arg(ap, u3_weak)) ) {
break;
}
else {
lit = u3nc(tem, lit);
}
}
va_end(ap);
}
return u3kb_flop(lit);
}
static u3_noun
_edit_cat(u3_noun big, c3_l axe_l, u3_noun som)