Listing Initial Appearances Inline

I think this problem covers several areas of I7 that I don’t understand well.

I’d like to be able to list the initial appearances of several objects all in one line (e.g. things supported by a table, or things that are edible). The setup might look something like this:

[code]The Study is a room.

The Desk is a supporter in the Study. The description is “A solid desk.[desk-notable]”

Notes are on the desk. “Scattered bits of notepaper are strewn about on the desk”

Pens are on the desk. “A jumble of pens lies about”

To say desk-notable:
if the desk supports something that is not handled:
say “[paragraph break]Well look at this. [list of initial appearances of items supported by the desk that are not handled].”[/code]

If this were to compile, I would expect desk-notable to print “Well look at this. Scattered bits of notepaper are strewn about on the desk, and a jumble of pens lies about.”

But I’m afraid I’m not that good with lists, and I’m not that good with phrases. Capitalization is a whole other issue I’m not ready to get into - but I’ve been able to fudge that one so far.

I’m embarrassed to even post my attempts at making this happen. Any recommendations would be appreciated.

This is too tricky for me (and I suspect having the new build with the list’s map function would be very handy here), but here is a start anyway:

The Study is a room.

The Desk is a supporter in the Study. The description is "A solid desk.[desk-notable]"

notes are on the desk. "scattered bits of notepaper are strewn about on the desk"

pens are on the desk. "a jumble of pens lies about"

To say desk-notable:
	let L be a list of text;
	repeat with item running through the list of not handled things on the desk:
		add the initial appearance of item to L;
	if L is not empty:
		say "[paragraph break]Well look at this: [run paragraph on]";
		say "[L].".

test me with "x desk / get notes / put notes on desk / x desk / get pens and notes / x desk"

which returns

Still not sure how to capitalize that sentence appropriately though.

I got about that far, but what I’d like to have is a general function for listing initial appearances for any collection of objects. I’m not sure if there’s a “to decide” or “to say” phrase that will take the description of the collection as an argument, or what the syntax for that might be.

In addition, it would be nice to have customized item introductions, such as:

… where the “one/another/third/last” comes from one list, and gets lined up with the initial appearances of a varying number of objects.

I wonder if this is fancy enough to make an extension, or if an extension exists to make it easier.

Well, sort of. There’s no extension to do exactly this, but the built-in Complex Listing extension lets you control the way things are named in lists and the way lists are delimited, which gets you partway there. Then some tweaking with indexed text will help you control the sentence case and strip out the punctuation in order to join short sentences together.

I’ve done the example so that it works for both LOOK and EXAMINE, but you could turn this off again by making the desk once more undescribed.

As it stands, this example will glue the initial appearances together into one sentence. If you want to see it with individual enumerated sentences (more like your second request), change

let N be “[prepared list delimited in appearance style]”;

to

let N be “[prepared list delimited in elaborate style]”;

[code]Include Complex Listing by Emily Short. Use the serial comma.

The Study is a room.

The Desk is a supporter in the Study. The description is “A solid desk.”

The Notes is on the desk. “Scattered bits of notepaper are strewn about on the desk.”

Pens are on the desk. “A jumble of pens lies about.”.

To say trimmed appearance of (target object - a thing):
let N be indexed text;
let N be “[initial appearance of the target object]”;
while N matches the regular expression “.”:
replace the regular expression “.” in N with “”;
say N.

Rule for writing a paragraph about a supporter (called target) which supports something:
say "Well look at this. ";
let N be indexed text;
if a not handled thing is on the target:
repeat with item running through not handled things which are on the target:
now the item is marked for special listing;
register things marked for listing;
let N be “[prepared list delimited in appearance style]”;
if a handled thing is on the target:
let N be “[N]; you also see”;
otherwise if a handled thing is on the target:
let N be “On [the target] you see”;
if a handled thing is on the target:
repeat with second item running through handled things which are on the target:
now the second item is marked for special listing;
register things marked for listing;
let N be “[N] [prepared list]”;
let N be “[N in sentence case]”;
say “[N].”

The examine containers rule is not listed in any rulebook.
The examine supporters rule is not listed in any rulebook.

Instead of examining a container:
carry out the writing a paragraph about activity with the noun.
Instead of examining a supporter:
carry out the writing a paragraph about activity with the noun.

Table of List Style Assignments (continued)
list style first delimiter second delimiter alternate second delimiter indefinite name phrase definite name phrase
appearance ", " "[if the serial comma option is active],[end if] and " " and " “[trimmed appearance of current listed object]” “[trimmed appearance of current listed object]”
elaborated ". " ". " ". " “[current enumeration in counting terms][trimmed appearance of current listed object]” "Finally, you see [trimmed appearance of the current listed object]. "

To say (N - a number) in counting terms:
if N is:
– 1: say "One thing you see is ";
– 2: say "The second is ";
– 3: say "Third, there’s ";
[add more here until your patience runs out]

test me with “look / x desk/get pens/put pens on desk/ look / x desk / get notes / put notes on desk / look / x desk”.[/code]

Also, re this specifically:

Yes, that can be done. 21.2. Descriptions as values discusses how to set this up, and the Complex Listing extension shows it in practice in the header of such phrases as “To prepare a/the/-- list of (selection - description of objects):”.

Thank you! That looks like it will more than take care of my needs.

I’ve put it into action, and it’s working well, but there is an issue with “sentence case.” I have some capitalized words in the intitial appearances (and in the handled object names), which are getting flattened by the sentence case. What I really need is to just change the case of the first character of the initial appearance. I would also be happy to do it this way:

The Notes is on the desk. "[S - in listing case]cattered sheets of notepaper from the Bronze Hotel are strewn about on the desk."

That way, you could even use:

Bronze Hotel notepaper is scattered about on the desk

or even:

bell hooks really likes the way the notepaper is scattered on the desk.

It seems like something I should be able to figure out, but the answer isn’t coming to me…

Of course it turned out the the capitalization problem had a very simple solution, thanks to indexed text! I wrote all the initial appearances with the first letter in lowercase, and then capitalized the first letter of the list text before tacking the introductory phrase onto the beginning. Since I’m not writing about bell hooks, that’s all I had to do…

The elaborated style didn’t quite work as I expected, though - it never got to the “Finally, you see…” line. I fixed it this way:

[code]Table of List Style Assignments (continued)
list style first delimiter second delimiter alternate second delimiter indefinite name phrase definite name phrase
elaborated ". " ". " ". " “[current enumeration out of current listing total in counting terms][trimmed appearance of current listed object]” "[current enumeration out of current listing total in counting terms][trimmed appearance of the current listed object]. "

To say (N - a number) out of (M - a number) in counting terms:
if N is M and M > 2:
say "Finally, you see ";
otherwise:
if N is:
– 1: say "One thing you see is ";
– 2: say "The second is ";
– 3: say "Third, there’s ";
[add more here until your patience runs out][/code]