From: Hallvard Tretteberg
Subject: format
Date: 
Message-ID: <HAL.93Aug16194716@monsun.si.no>
I'm trying to make a format string that generates nice type names. If
given the type '(or type1 type2) I want it to print "TYPE1 or TYPE2",
if it is given '(or type1 type2 type3) I want it to print "TYPE1,
TYPE2 or TYPE3". In general it should print "OR" between the last two
types in the and a comma in other cases. Is there an elegant way to do
it. The best would be to have a kind of escape construct that test the
number of remaining args and uses that to choose a subformat string.

Any ideas?

--
Hallvard Traetteberg
Dept. of Knowledge Based Systems
SINTEF SI
Box 124 Blindern, 0314 Oslo 3
NORWAY

Tlf: +47 22 06 79 83 or  +47 22 06 73 00
Fax: +47 22 06 73 50
Email: ···················@si.sintef.no
From: Steve Haflich
Subject: Re: format
Date: 
Message-ID: <SMH.93Aug17052559@akbar.Franz.COM>
In article <·················@monsun.si.no> ···@si.no (Hallvard Tretteberg) writes:

   I'm trying to make a format string that generates nice type names. If
   given the type '(or type1 type2) I want it to print "TYPE1 or TYPE2",
   if it is given '(or type1 type2 type3) I want it to print "TYPE1,
   TYPE2 or TYPE3". In general it should print "OR" between the last two
   types in the and a comma in other cases. Is there an elegant way to do
   it. The best would be to have a kind of escape construct that test the
   number of remaining args and uses that to choose a subformat string.

If you want to write a format clause that takes an _arbitrary_ Lisp
type specifier such as (or (satisfies frob-p) (and (or foo bar) boo)
and describes it in English, then this is beyond the capabilities of
format.  But if the problem you need to solve is specifically printing
a comma-separated list with an "or" before the last item, then the
example on CLtL2 p.602 is nearly exactly what you want.