From: David J. Cooper
Subject: format directive "~{...~}"
Date: 
Message-ID: <3877DA2B.209F208C@genworks.com>
Happy New Year to all!

I am wondering about using the ~{....~} format directive,
or a similar format directive, to place something before
all but the first element in an argument list.

First, a belated thanks to everyone who helped clarify the
usage of ~{...~^...~} a few months back.

This has been saving me a lot of messy code lately.

As we now know, the ~^ directive allows one to put something
after each element except the last element in the argument 
list, as in:

> (format nil "~{~a~^, ~}" (list 1 2 3 4 5))
"1, 2, 3, 4, 5"

Now I am wondering if there is a way to use this or a similar
directive to put something before all but the first element in
the list, as in:

> (format nil "(~{~a~^,~%~}))" (list one two three))
"(one,
two,
three)"

If possible I would like to extend the above so it outputs

"(one
 two
 three)"

that is, I want an extra space *before* all but the *first* 
element in the argument list, so that the rest of the elements
line up under the first one which has a parenthesis to the left
of it.

In case you are curious, this is for emitting neat-looking SQL
statements, like:

CREATE TABLE TRY
(LAST_NAME VARCHAR(30),
 FIRST_NAME VARCHAR(30),
 SSN VARCHAR(10))

etc.

Thanks for any wisdom!

 -dave

-- 
David J. Cooper Jr, Chief Engineer	Genworks International
·······@genworks.com			5777 West Maple, Suite 130
(248) 932-2512 (Genworks HQ/voicemail)	West Bloomfield, MI 48322-2268
(248) 407-0633 (pager)			http://www.genworks.com