add variable argument append.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-11 21:50:59 +02:00
parent 3a29b03529
commit ddccd4747a
2 changed files with 13 additions and 6 deletions

View file

@ -11,7 +11,7 @@ mes: mes.c mes.h
mes.h: mes.c GNUmakefile
( echo '#if MES'; echo '#if MES' 1>&2;\
grep -E '^(scm [*])*[a-z_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
grep -E '^(scm [*])*[a-z0-9_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
while read f; do\
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\

17
mes.c
View file

@ -280,7 +280,7 @@ apply_ (scm *fn, scm *x, scm *a)
if (fn == &scm_symbol_current_module) // FIXME
return a;
if (eq_p (fn, &scm_symbol_call_with_values) == &scm_t)
return call (&scm_call_with_values_env, append (x, cons (a, &scm_nil)));
return call (&scm_call_with_values_env, append2 (x, cons (a, &scm_nil)));
if (builtin_p (fn) == &scm_t)
return call (fn, x);
return apply (eval (fn, a), x, a);
@ -497,13 +497,20 @@ call (scm *fn, scm *x)
}
scm *
append (scm *x, scm *y)
append2 (scm *x, scm *y)
{
if (x == &scm_nil) return y;
assert (x->type == PAIR);
return cons (car (x), append (cdr (x), y));
return cons (car (x), append2 (cdr (x), y));
}
scm *
append (scm *x/*...*/)
{
if (x == &scm_nil) return &scm_nil;
return append2 (car (x), append (cdr (x)));
}
scm *
make_char (int x)
{
@ -689,7 +696,7 @@ lookup_char (int c, scm *a)
}
char *
list2str (scm *l)
list2str (scm *l) // char*
{
static char buf[256];
char *p = buf;
@ -722,7 +729,7 @@ vector_to_list (scm *v)
{
scm *x = &scm_nil;
for (int i = 0; i < v->length; i++)
x = append (x, cons (v->vector[i], &scm_nil));
x = append2 (x, cons (v->vector[i], &scm_nil));
return x;
}