Previous: , Up: Basic Formatting   [Contents][Index]


6.4.3.3 English Language Directives

These directives allow you to emit numbers as English words, to emit plural markers based on the value of a format argument, and to apply case conversions to sections of FORMAT’s output.

~R

when used with no base specified, prints numbers as English words or Roman numerals

When used with no prefix parameter and no modifiers, it emits the number in words as a cardinal number

With the colon modifier, it emits the number as an ordinal

And with an at-sign modifier, it emits the number as a Roman numeral; with both an at-sign and a colon, it emits "old-style" Roman numerals in which fours and nines are written as IIII and VIIII instead of IV and IX.

~P

simply emits an s unless the corresponding argument is 1. Typically, however, you’ll use ~P with the colon modifier, which causes it to reprocess the previous format argument.

(format nil "~r file~:p" 10) ==> "ten files"

With the at-sign modifier, which can be combined with the colon modifier, ‘~P’ emits either ‘y’ or ‘ies’.

(format nil "~r famil~:@p" 10) ==> "ten families"
~(

allows you to control the case of text in the output. all the output generated by the portion of the control string between the two markers will be converted to all lowercase.

You can modify ~( with an at sign to make it capitalize the first word in a section of text

with a colon to make it to capitalize all words,

with both modifiers to convert all text to uppercase.

(format nil "~(~a~)" "tHe Quick BROWN foX")   ==> "the quick brown fox"
(format nil "~@(~a~)" "tHe Quick BROWN foX")  ==> "The quick brown fox"
(format nil "~:(~a~)" "tHe Quick BROWN foX")  ==> "The Quick Brown Fox"
(format nil "~:@(~a~)" "tHe Quick BROWN foX") ==> "THE QUICK BROWN FOX"

Previous: Character and Integer Directives, Up: Basic Formatting   [Contents][Index]