From: Dave Bakhash
Subject: FORMAT and cardinal nos.
Date: 
Message-ID: <c29vgfot15f.fsf@nerd-xing.mit.edu>
Hi,

I thought I once remmebered reading about FORMAT being able to do
cardinality (or whatever that's caled), i.e.

(format nil "~<some-character>" 3)

==> "third"

Does format do that?  If so, what's the directive?  I looked through the
CLHS, but didn't see it there.  What _was_ there was the ~R directive,
which would print "three" in the above case, but I want "third", etc.

thanks,
dave

From: Barry Margolin
Subject: Re: FORMAT and cardinal nos.
Date: 
Message-ID: <VFSO7.15$hR1.4631@burlma1-snr2>
In article <···············@nerd-xing.mit.edu>,
Dave Bakhash  <·····@alum.mit.edu> wrote:
>I thought I once remmebered reading about FORMAT being able to do
>cardinality (or whatever that's caled), i.e.
>
>(format nil "~<some-character>" 3)
>
>==> "third"

That's ordinal.

>Does format do that?  If so, what's the directive?  I looked through the
>CLHS, but didn't see it there.  What _was_ there was the ~R directive,
>which would print "three" in the above case, but I want "third", etc.

If you read the full description of ~R, you'd see that the : modifier
does what you want.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Raymond Wiker
Subject: Re: FORMAT and cardinal nos.
Date: 
Message-ID: <868zck6jsg.fsf@raw.grenland.fast.no>
Dave Bakhash <·····@alum.mit.edu> writes:

> Hi,
> 
> I thought I once remmebered reading about FORMAT being able to do
> cardinality (or whatever that's caled), i.e.
> 
> (format nil "~<some-character>" 3)
> 
> ==> "third"
> 
> Does format do that?  If so, what's the directive?  I looked through the
> CLHS, but didn't see it there.  What _was_ there was the ~R directive,
> which would print "three" in the above case, but I want "third", etc.

        Try "~:R" instead of "~R":

* (format t "~a ~R ~:R~%" 3 3 3)
3 three third


-- 
Raymond Wiker                        Mail:  ·············@fast.no
Senior Software Engineer             Web:   http://www.fast.no/
Fast Search & Transfer ASA           Phone: +47 23 01 11 60
P.O. Box 1677 Vika                   Fax:   +47 35 54 87 99
NO-0120 Oslo, NORWAY                 Mob:   +47 48 01 11 60

Try FAST Search: http://alltheweb.com/
From: Eric Moss
Subject: Re: FORMAT and cardinal nos.
Date: 
Message-ID: <3C0D99DB.17FAEB64@alltel.net>
Raymond Wiker wrote:
> 
> Dave Bakhash <·····@alum.mit.edu> writes:
>         Try "~:R" instead of "~R":
> 
> * (format t "~a ~R ~:R~%" 3 3 3)
> 3 three third

Note, however, if you have an older copy of lispworks, you might have
trouble with certain negative multiples of 10 (they fixed it a few
months ago):

(format nil "~:R" -90)
=> "ninetieth"

(format nil "~:R" -80)
=> "eightieth"

(format nil "~:R" -89)
=> "minus eighty-ninth"


Eric
From: Erik Naggum
Subject: Re: FORMAT and cardinal nos.
Date: 
Message-ID: <3216414750127957@naggum.net>
* Dave Bakhash <·····@alum.mit.edu>
| Does format do that?  If so, what's the directive?  I looked through the
| CLHS, but didn't see it there.  What _was_ there was the ~R directive,
| which would print "three" in the above case, but I want "third", etc.

  Check out the : and @ modifiers to format control characters.

///
-- 
  The past is not more important than the future, despite what your culture
  has taught you.  Your future observations, conclusions, and beliefs are
  more important to you than those in your past ever will be.  The world is
  changing so fast the balance between the past and the future has shifted.