From: Jimmy Miller
Subject: Passing &rest values from one function to another
Date: 
Message-ID: <fae68dd4-2762-4d49-99c2-02850aef10f0@j12g2000vbl.googlegroups.com>
I'd like to have the &rest parameter list for one function become the
&rest list for another, as in:

(defun rest-1 (&rest xs)
  (rest-2 xs))

(defun rest-2 (&rest ys)
  ys)

(rest-1 1 2 3) ;;If all went according to plan, this would return '(1
2 3), not '((1 2 3))

Is there a Lisp idiom for doing this?  I thought of writing a macro
elements-of that would function as follows:

(elements-of '(1 2 3)) => (nth 0 '(1 2 3)) (nth 1 '(1 2 3)) (nth 2 '(1
2 3))

But I don't know if it's possible to return multiple forms from a
macro like this.  I can't just wrap them in something like progn
because all three elements need to be passed as parameters.

Any advice would be appreciated.

From: Pascal Costanza
Subject: Re: Passing &rest values from one function to another
Date: 
Message-ID: <7andu6F1vajpaU1@mid.individual.net>
Jimmy Miller wrote:
> I'd like to have the &rest parameter list for one function become the
> &rest list for another, as in:
> 
> (defun rest-1 (&rest xs)
>   (rest-2 xs))

(defun rest-1 (&rest xs)
   (apply #'rest-2 xs))

> 
> (defun rest-2 (&rest ys)
>   ys)
> 
> (rest-1 1 2 3) ;;If all went according to plan, this would return '(1
> 2 3), not '((1 2 3))


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Jimmy Miller
Subject: Re: Passing &rest values from one function to another
Date: 
Message-ID: <ee56b6cf-628e-4454-a875-8e8e4a48a01a@l32g2000vbp.googlegroups.com>
On Jun 27, 4:32 pm, Pascal Costanza <····@p-cos.net> wrote:
> Jimmy Miller wrote:
> > I'd like to have the &rest parameter list for one function become the
> > &rest list for another, as in:
>
> > (defun rest-1 (&rest xs)
> >   (rest-2 xs))
>
> (defun rest-1 (&rest xs)
>    (apply #'rest-2 xs))
>
>
>
> > (defun rest-2 (&rest ys)
> >   ys)
>
> > (rest-1 1 2 3) ;;If all went according to plan, this would return '(1
> > 2 3), not '((1 2 3))
>
> Pascal
>
> --
> My website:http://p-cos.net
> Common Lisp Document Repository:http://cdr.eurolisp.org
> Closer to MOP & ContextL:http://common-lisp.net/project/closer/

Now I feel stupid.  Thanks Pascal.