Subject: Re: With format, how to print a variable number of spaces
From: (Rob Warnock)
Date: Tue, 06 Jun 2006 21:04:35 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Pascal Bourguignon  <> wrote:
| Kent M Pitman <> writes:
| > So if you do:
| >   (defun spaces (n) (format nil "~V{ ~}" n '(IGNORED)))
| > you'll get what you want if you want to use FORMAT.
| > ...  not that I'd advocate FORMAT.  ...
| It seems to me that:
|     (format t "~V,,,VA" width fill "")
| is more readable and better: it gives format an opportunity to do it
| more efficiently.

Indeed. But Kent's method raises another interesting possibility,
for when the thing you want to repeat multiple times isn't a
single character:

    > (loop for i below 4 do
        (format t "I'm so~V{ ~A~:*~} happy!~%" i '("very")))
    I'm so happy!
    I'm so very happy!
    I'm so very very happy!
    I'm so very very very happy!


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607