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.
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/
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.