On 23/08/2025 17:49, Janis Papanagnou wrote:
Often we stumble across text output from software, like
Copy 42 items (12 minutes left).
...
Copy 1 items (1 minutes left).
Since I'm also doing a lot of text oriented processing
I'm usually using some pluralization, e.g. in "C" like
printf ("Copy %d item%s ...", n, (n>1 ? "s" : "") );
Firstly, I agree with Keith that English uses the
plural in the case n = 0; n < 0 is, I suppose, unlikely to
occur in real examples.
[...]. So instead of inline-ternary operators ?:
or procedures these Algol 68 operator variants emerged:
PRIO PLURAL = 6;
OP PLURAL = (INT amount, STRING word) STRING :
whole (amount, 0) + word + ( amount > 1 | "s" | "" );
Secondly, if you're generalising, then you "should" look
at the end of "word": eg "flies" rather than "flys". I accept,
of course, that there are limits to how much should be done; you
can spend years tweaking stuff like that.
alleviating the application text from "stringifying"
with an explicit whole(n,0) or conditionals. Producing
output (depending on the variant) like
Get 1 horse or 2 dogs or 3 cats or 12 fleas to get happy.
Not really relevant, but I recall David Crystal grumbling
about the calls for phonetic spelling, and pointing out that we
usually get plurals by adding "s", but phonetically we would have
"cats", "dogz" and "horsiz", and a mess!
--
Andy Walker, Nottingham.
Andy's music pages: www.cuboid.me.uk/andy/Music
Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Grieg
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)