Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FORMAT and cardinal nos.

4 views
Skip to first unread message

Dave Bakhash

unread,
Dec 3, 2001, 5:00:12 PM12/3/01
to
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

Barry Margolin

unread,
Dec 3, 2001, 5:04:37 PM12/3/01
to
In article <c29vgfo...@nerd-xing.mit.edu>,

Dave Bakhash <ca...@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, bar...@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.

Raymond Wiker

unread,
Dec 3, 2001, 5:06:07 PM12/3/01
to
Dave Bakhash <ca...@alum.mit.edu> writes:

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

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


--
Raymond Wiker Mail: Raymon...@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/

Erik Naggum

unread,
Dec 3, 2001, 7:32:31 PM12/3/01
to
* Dave Bakhash <ca...@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.

Eric Moss

unread,
Dec 4, 2001, 10:51:55 PM12/4/01
to
Raymond Wiker wrote:

>
> Dave Bakhash <ca...@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

0 new messages