[plt-scheme] rest args

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Feb 7 12:58:17 EST 2004

On Feb  7, David J. Neu wrote:
> 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.
> 
> (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)))

Use (apply f a b z) in the last line.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.