[plt-scheme] rest args

From: ifconfig (ifconfignslookup at hotmail.com)
Date: Sat Feb 7 12:57:24 EST 2004

Try something like
 
(define (f . z)
  'blah-blah-blah
  (apply g z))

(define (g . z)
  'yada-yada-yada)

ifconfig
BAGOS
http://bagos.sourceforge.net


----- Original Message ----- 
From: "David J. Neu" <djneu at att.net>
To: <plt-scheme at list.cs.brown.edu>
Sent: Saturday, February 07, 2004 7:54 PM
Subject: [plt-scheme] rest args


>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> Hi,
> 
> I'm not sure if the following question is appropriate for this list,
> if not please let me know the best place to post.
> 
> I have an application, in which I have two procedures (see simplified
> example below):
>   - f can be called directly or by g
>   - g calls f
>   - both f and g have a rest parameter z
> 
> The problem I'm encountering is that when g calls f, parameter z comes
> in as a list containing a list - obviously not what I want since when
> f is called directly z is a simple list.
> 
> Many thanks in advance!
> 
> --David
> 
> 
> (define f
>   (lambda (a b . z)
>     (printf "~a~n" a)
>     (printf "~a~n" b)
>     (printf "~a~n" z)))
> 
> (define g
>   (lambda (a b c . z)
>     (printf "~a~n" a)
>     (printf "~a~n" b)
>     (printf "~a~n" c)
>     (printf "~a~n~n" z)
>     (f a b z)))
> 
> > (f 1 2 '("user" . "myuser") '("password" . "mypass"))
> 1
> 2
> ((user . myuser) (password . mypass))
> 
> > (g 1 2 3 '("user" . "myuser") '("password" . "mypass"))
> 1
> 2
> ((user . myuser) (password . mypass))
> 
> 1
> 2
> (((user . myuser) (password . mypass)))
> 


Posted on the users mailing list.