Programming Challenge Numbers to Text?

Shane Hathaway shane at hathawaymix.org
Fri May 5 16:32:49 MDT 2006


Levi Pearson wrote:
> On May 5, 2006, at 4:06 PM, Shane Hathaway wrote:
> 
>> It just looks like feature bloat, that's all.  I don't recall ever  
>> seeing a need for this functionality (until this thread).
>>
>> What I *do* see a need for, however, is something that  automatically 
>> pluralizes properly, so that the system can output  "finished 1 copy" 
>> instead of "finished 1 copys", "finished 1  copies", or the cop-out, 
>> "finished 1 copy(ies)".  If Lisp has that  functionality built in, 
>> that would impress me, even if it's English- only.
> 
> 
> So, for your example, you'd do: (format t "Finished ~R cop~:@P" n)
> 
> Which would print either "Finished one copy." or something like  
> "Finished two copies."
> 
> The ~:@P tells it to back up an argument (since the n was already  
> consumed by the ~R) and print either y or ies depending on the  number.  
> ~P itself prints an s or nothing depending on the number of  the argument.
> 
> Or even "Finished one thousand three hundred sixty-two copies."

Ok, now that's cool.  Thanks.

Shane


More information about the PLUG mailing list