Can you find containers/supporters in a list without a loop?

Hi,

Suppose you have a list of things some of which are containers and or supporters.

Is there a way of pointing to just one (say the first) without having to wade through with a ‘repeat with thing running through list’ loop?

I tried varous combinations of

Let thingy be the first container in the mire;

Where mire is the list of objects but Inform just complains however I try with …

which doesn’t really tell me if its just a syntax issue (something I keep falling over with inform) or simply not possible.

Any ideas?.

I think you’re looking for

let thingy be a random container in the mire

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].";

Hi,

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.

Many thanks for the reply Zarf , more reading ahead…

I wonder if my failure (amongst many failures) to understand the concept of a relation in Inform is tripping me on another section of code…

now every item held in stuff that is not an enclosure is not marked for listing;

its erroring with