Week 4

Adieu, Adieu

A list you grow until the person ends input, then a package that knows English commas.

You type

Names, one per line, until the person is done.

The tool
Collect names, then join them Ask for a name Add it to a list again
What comes out

One farewell line that lists the names.

The question, more slowly

The question is: collect at least one name, one per line, until the person ends input, then print a single farewell that lists the names in English. Two names use 'and'. Three or more use commas and a final 'and'. The line always starts with the farewell words in the spec.

Keep the names in a list. Do not format the sentence yourself if you can help it. The inflect package, linked from the spec, knows how English joins a list. Your job is the loop and the call. On a Mac, Control-D ends input.

People hard-code three names, or they put a comma before 'and' when there are only two names. Try one name, then two, then three.

Before you code

Collect names into a list until input ends, and print the list with no sentence around it. Formatting the farewell is the problem, and the package docs show the join.