Listing things that are involved in a relationship

Hey guys. I started using a relationship between things, and then I wanted to iterate over all things that are part of such a relationship. I figured it would be easy… and I’m sure it is.

Here’s what I’ve got:

Section - Partnering

Partnering relates one thing to another (called partner).

The verb to partner with implies the partnering relation.

[there is probably something neater than this]
to decide whether (T - a thing) is partnered:
	if the partner of T is not nothing, yes;

[And this?]
definition: a thing is partnered if it is partnered;

Section - demo

the demo is a room.

Foo, Bar, Quux and Zop are things.

Foo partners with Bar. Quux partners with Zop.

statting is an action out of world applying to nothing. 

Understand "stat" as statting. 

carry out statting:
	repeat with T running through the list of partnered things:
		say "[T] - [the partner of T].".

test me with "stat".

I mean, it works, but I have a feeling I am doing things in a very circuitous fashion. I mean - “definition: a thing is partnered if it is partnered;”. Really? Anybody want to show me a more elegant way to do it?

Aha! This works!

definition: a thing is partnered if the partner of it is not nothing.

Plus you’ve got another one for this list:


On your code I suspect you could also use “Definition: a thing is partnered if it partners something” or “if something partners it,” but defining the “partner” property is also OK.

For completeness, the way Matt suggests does work, except I had an extra “with”. I think that’s the neatest way to phrase it:

definition: a thing is partnered if it partners with something.

And I guess I was not that far off track, making a definition seems to be the trick that lets you refer to things like “all partnered things carried by the player”.

Yeah. A “Definition:” line creates an adjective, which can then be used in descriptions like “all ADJ things”.

And it’s often useful to define the antonym at the same time:

Definition: a thing is partnered rather than unpartnered if it partners with something.

Ooh, nice. Thanks Dannii, I hadn’t seen that.