Programming Challenge Numbers to Text?
Levi Pearson
levi at cold.org
Fri May 5 16:30:44 MDT 2006
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."
--Levi
More information about the PLUG
mailing list