[plt-scheme] rest args

From: David J. Neu (djneu at att.net)
Date: Sat Feb 7 12:54:02 EST 2004

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.