Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!shelby!snorkelwacker.mit.edu!ira.uka.de!opal!net From: net@opal.cs.tu-berlin.de (Oliver Laumann) Newsgroups: comp.lang.misc Subject: Re: Printing plural forms. Message-ID: <2706@kraftbus.cs.tu-berlin.de> Date: 19 Feb 91 13:04:52 GMT References: <1991Feb19.104810.549@ZYX.SE> Organization: Technical University of Berlin, Germany Lines: 25 In article <1991Feb19.104810.549@ZYX.SE> arndt@zyx.ZYX.SE (Arndt Jonasson) writes: > We all have seen and, in various degrees, been irritated by texts such as: > > 1 files were copied > > when it should have been: > > 1 file was copied > > I'd like to know: when programming, how do you avoid such errors? Are > there features in the programming language you use (or other languages > you know) that make plural handling especially easy or difficult? The Common Lisp function "format" has a mechanism to automatically pluralize a word by appending an `s' when appropriate. This is no wonder considering that "format" even has formatting requests to print a number with roman numerals or as english words (e.g. "twentyfour files copied")... In C, a common idiom (well, at least in my programs) is printf("%d file%s copied.\n", nfiles, "s"+(nfiles==1)); -- Oliver Laumann net@tub.cs.tu-berlin.de net@tub.UUCP net@pogo.ai.mit.edu