You do need “a random…” Unfortunately this isn’t sufficient, because Inform defines “listed in” as a phrase rather than a relation.
You can add this in, though:
The apple is a thing.
The box is a container.
The table is a supporter.
The rock is a thing.
List-containment relates a value (called T) to a list of values (called L) when T is listed in L.
The verb to be rlisted in implies the list-containment relation.
Instead of jumping:
let L be {apple, box, table, rock};
say "L is [L].";
let T be a random container rlisted in L;
say "T is [T].";
Many thanks for these. Curiously my final code chunk of;
let item be a random enclosure that is marked for listing held by the thingy;
say "enclosure picked is [item]";
(I defined enclosure as a thing and then container and supporter as kinds of enclosure.)
works without the need for the list containment suggested by Zarf. I have no idea why though!
Is there any way of finding the first container/enclosure?
I am guessing no as there is no internal indexing of lists in Inform? I’m also guessing that random forces it to do a search of some kind? Reason I ask is that I seem to remember that you can find the first item in a list of kinds of value - but can’t rmember where I found this.
That line works because “held by” is a relation (the holding relation), and “marked for listing” is an adjective (because it is a binary property). Inform is good at computing descriptions made from relations and adjectives. Boolean phrases are awkward and mess things up.
You can get at array entries by number – see chapter 20.9. I’m not sure about finding the first object in a described set, though.