Inform 7 Home Page / Documentation


§21.3. Saying lists of values

Any list L can be said, provided that its contents can be said. For example:

let L1 be {2, 3, 5, 7, 11};
say L1;

produces the text "2, 3, 5, 7 and 11" - unless we have "Use serial comma." set, in which case a comma appears after the 7. We also have the option of using the more formal notation:

say "[(list of values) in brace notation]"

This text substitution produces the list in the form of "{", then a comma-separated list, and then "}", which looks less like an English sentence but more mathematical. Example:

"[list of people in brace notation]"

might produce "{ yourself, Mr Darcy, Flashman }".

If we say a list of lists, then the individual entry lists are always printed in brace notation: the ordinary sentence way would be incomprehensible.

Of course, the values in L1 are written out in number form because L1 is a list of numbers: we could alternatively try

let L2 be {the piano, the music stand};
say L2;

which produces "piano and music stand". Lists of objects can be said in two additional ways:

say "[(list of objects) with definite articles]"

This text substitution writes out the list in sentence form, adding the appropriate definite articles. Example:

let L be {the piano, the music stand};
say "[L with definite articles]";

says "the piano and the music stand".

say "[(list of objects) with indefinite articles]"

This text substitution writes out the list in sentence form, adding the appropriate indefinite articles. Example:

let L be {the piano, the music stand};
say "[L with definite articles]";

says "a piano and a music stand".


arrow-up.png Start of Chapter 21: Lists
arrow-left.png Back to §21.2. Constant lists
arrow-right.png Onward to §21.4. Testing and iterating over lists

*ExampleOyster Wide Shut
Replacing Inform's default printing of properties such as "(closed)", "(open and providing light)", etc., with our own, more flexible variation.