# How to construct a list of things which satisfy a specific condition?

I’ve been looking at this in the documentation and here but I can’t find it.

I have a bunch of objects that have a number associated to them. I want to make a list of everything that has a ‘1’ as its number. Here’s the code; all of the attempts to make a list at the bottom fail to compile.

``````Playroom is a room.

A thing has a number called the secret-number.

The ball is a thing. The secret-number of the ball is 1.
The block is a thing. The secret-number of the block is 1.
The string is a thing. The secret-number of the string is 2.

When play begins:
say "You can see [a list of things with secret-number 1]";
say "You can see [a list of things with a secret-number of 1]";
say "You can see [a list of things which have secret-number equal to 1]";
say "You can see [a list of secret-number 1 things]";
``````

This is one of the harder-to-find Inform tricks, I’m afraid.

``````A thing has a number called the secret-number.

The verb to secretly-number means the secret-number property.

The ball is a thing. The secret-number of the ball is 1.
The block is a thing. The secret-number of the block is 1.
The string is a thing. The secret-number of the string is 2.

When play begins:
say "You can see [a list of things which secretly-number 1].";

``````

(This is chapter 15.12.)

10 Likes

Thank you, I would not have found that in a million years.

1 Like
``````Definition: a thing is secret-one if the secret-number of it is 1.

When play begins: say list of secret-one things.
``````

A definition could do it, too.

5 Likes

And if the number isn’t a property, but is e.g. something calculated by a phrase, you can make a new relation:

``````To decide what number is the (item - a thing) hashed:
decide on the number of letters in "[item]".

Hashing relates a thing (called X) to a number (called Y) when X hashed is Y.
The verb to hash to means the hashing relation.

When play begins: say the list of things that hash to 5.
``````
3 Likes

Inform 7 itself is the greatest text adventure, but some of its puzzles are I think unfair. Good to know this one has multiple solutions though.

7 Likes