Hans Aberg <haber...@telia.com> writes: > The reply I got was helpful, but I decided to settle for a macro > implementation: > > (use-syntax (ice-9 syncase)) > > (define-syntax tuple > (syntax-rules () > ((tuple xs ...) > `(tuple ,xs ...)) > ((tuple x1 x2 . y) > (append `(tuple ,x1 ,x2) y)) > ((tuple x1 . y) > (append `(tuple ,x1) y)) > ))
OK, I roughly see that this solves your problem of wanting to unquote an arbitrary number of list elements. (Although I don't understand why you need to do that.) > It behaves as I want in my context, a functional language on top of > Guile. Scheme is already a functional language, isn't it? > I decided to implement the construct (lambda (x_1 ... x_k . y) > f) What syntax is that expression in? In Scheme syntax, it's a lambda that returns a value that is apparently unrelated to any of the arguments, and so could equally well be written as (lambda ignored-args f). > using an improper list (x_1 ... x_k . y); when it is a proper list, > one just gets the fixed number of arguments construct. > > Then the object (x_1 ... x_k . y) also become available, so it is > possible to form > (define f (lambda (x_1 ... x_k . y) (x_1 ... x_k . y))) How is this different from (define f (lambda args args)) ? > Then one would expect f(a_1, ..., a_n), for n >= k, to be (a_1, ..., > a_n) - this a form of the identity. > > So to get this effect, I need a function g that can call improper > lists (g x_1, ..., x_k . y), where y is a list. As Dan pointed out, that is not an improper list. It's a proper list. In the hope that these questions might be useful to at least one of us... Neil