Hi,
I need help in figuring out a format statement.
(setq a "org")
(setq b "chris dan ski elaine nick tony charlie jeff jeffw bruce mike kim kelly")
or a list of names
(setq b '("chris" "dan" "ski"...))
What format string
(format "???" a b)
will print them in this format
org: chris dan ski elaine nick tony charlie
jeff jeffw bruce mike kim kelly
Thanks in advance
Cheers,
Chris "ski" Kacoroski "When we try to pick out anything by itself
···@atc.boeing.com we find it connected to the entire universe"
John Muir
In article <······················@grace.boeing.com> ···@atc.boeing.com writes:
>(setq a "org")
>(setq b "chris dan ski elaine nick tony charlie jeff jeffw bruce mike kim kelly")
>
>or a list of names
>
>(setq b '("chris" "dan" "ski"...))
You'll have to write your own routine to convert the single-string form
into a list of strings. Common Lisp has nothing that will parse the string
into words and treat them separately for this purpose (the only thing in CL
that deals with words is STRING-CAPITALIZE).
>What format string will print them in this format
>
>org: chris dan ski elaine nick tony charlie
> jeff jeffw bruce mike kim kelly
Once you've got a list of words in B, you can make use of the ~<...~:;...~>
FORMAT directive to fill the line with them.
(format t "~&~A:~7T~{~<~%~7T~:; ~A~>~}~%" a b)
This is similar to the example in CLtL for printing a comma-separated list
of items.
--
Barry Margolin
System Manager, Thinking Machines Corp.
······@think.com {uunet,harvard}!think!barmar
Chris Kacoroski,none (···@atc.boeing.com) wrote:
: Hi,
:
: I need help in figuring out a format statement.
:
:
: What format string
:
:
: will print them in this format
:
: org: chris dan ski elaine nick tony charlie
: jeff jeffw bruce mike kim kelly
:
See the FAQ [3-14], which gives a template for this type of printing.
In article <······················@grace.boeing.com> ···@atc.boeing.com writes:
>(setq a "org")
>(setq b
> "chris dan ski elaine nick tony charlie jeff jeffw bruce mike kim kelly")
>or (setq b '("chris" "dan" "ski"...))
>
>What format string
>(format "???" a b)
>will print them in this format
>
>org: chris dan ski elaine nick tony charlie
> jeff jeffw bruce mike kim kelly
Using (setq b '("chris" "dan" "ski" ...)) the following works
(format t "~A:~{~8T~A~^ ~A~^ ~A~^ ~A~^ ~A~^ ~A~^ ~A~^~%~}" a b)
The first ~A uses up a.
The ~{...~} is processed repeatedly on elements of b until all are used.
The 8T gets to the correct column.
The ~^ are so processing will stop without error regardless of the
length of b.
I wasted an hour on that, but I learned something. Merry Christmas!
This worked in Allegro Common LISP on a SUN4.
Tom Kramer
······@cme.nist.gov
In article <·····@cosmos.cme.nist.gov> ······@cme.nist.gov (Tom Kramer) writes:
In article <······················@grace.boeing.com> ···@atc.boeing.com writes:
>What format string
>(format "???" a b)
>will print them in this format
>
>org: chris dan ski elaine nick tony charlie
> jeff jeffw bruce mike kim kelly
Using (setq b '("chris" "dan" "ski" ...)) the following works
(format t "~A:~{~8T~A~^ ~A~^ ~A~^ ~A~^ ~A~^ ~A~^ ~A~^~%~}" a b)
I wasted an hour on that, but I learned something. Merry Christmas!
To paraphrase the old TECO joke:
"FORMAT. A moment of convenience. A lifetime of regret."