Hi,
I'm trying to figure out how to use &rest for the following function:
(defun show-output (format-string &rest parameters)
(when *show-output*
(funcall #'format t format-string parameters)))
This is obviously wrong, since the parameters are sitting in a list,
and will be treated as one big parameter. How do I get them out and
pass them as atomic units to format?
On Nov 9, 3:30 pm, Q <······@gmail.com> wrote:
> Hi,
>
> I'm trying to figure out how to use &rest for the following function:
>
> (defun show-output (format-string &rest parameters)
> (when *show-output*
> (funcall #'format t format-string parameters)))
>
> This is obviously wrong, since the parameters are sitting in a list,
> and will be treated as one big parameter. How do I get them out and
> pass them as atomic units to format?
Use APPLY.
On Fri, 09 Nov 2007 06:30:03 -0800, Q <······@gmail.com> wrote:
> I'm trying to figure out how to use &rest for the following function:
>
> (defun show-output (format-string &rest parameters)
> (when *show-output*
> (funcall #'format t format-string parameters)))
>
> This is obviously wrong, since the parameters are sitting in a list,
> and will be treated as one big parameter. How do I get them out and
> pass them as atomic units to format?
Use APPLY instead of FUNCALL.
http://www.lispworks.com/documentation/HyperSpec/Body/f_apply.htm
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
Q <······@gmail.com> writes:
> I'm trying to figure out how to use &rest for the following function:
>
> (defun show-output (format-string &rest parameters)
> (when *show-output*
> (funcall #'format t format-string parameters)))
Just substitute apply for funcall.
--
Frode Vatvedt Fjeld