# [i7] Checking to see if a value is the same as any other

I have a list of objects which can each have a numerical value. What’s the easiest way to check whether any of the objects share the same value?

For instance, let’s say it was:

```The position of Mercury is 1. The position of Venus is 3. The position of Earth is 5. The position of Mars is 8.```

And I increased the position of Mercury by 2. Now obviously I could have a condition saying “If the position of mercury equals the position of venus” etc. for all the possible objects, but there’s definitely a better way than that.

``````a planet is a kind of thing.
the plural of planet is planets.
a planet has a number called position.

Mercury is a planet.
The position is 1.

Venus is a planet.
The position is 3.

Earth is a planet.
The position is 5.

Mars is a planet.
The position is 8.

to decide which list of planets is the planets at position (pos - a number):
let result be a list of planets;
repeat with planet running through the list of planets:
if the position of planet is pos:
decide on result.

Obligatory test room is a room.

when play begins:
say "[the planets at position 3].".``````

To compare with a planet rather than a number add this decide phrase:

``````to decide which list of planets is the planets at the position of (p - a planet):
let result be a list of planets;
repeat with planet running through the list of planets:
if the position of planet is the position of p:
decide on result.``````

[code]Collocation relates a planet (called X) to a planet (called Y) when the position of X is the position of Y. The verb to be collocated with means the collocation relation.

If Mercury is collocated with a planet:[/code]

ETA: Didn’t look up the syntax, so I may have got it wrong.

Oh that’s great. Thanks for he swift replies!

Relations also work here.

``````a planet is a kind of thing.
the plural of planet is planets.
a planet has a number called position.

Mercury is a planet.
The position is 1.

Venus is a planet.
The position is 3.

Earth is a planet.
The position is 5.

Mars is a planet.
The position is 8.

proximity relates a planet (called p1) to a planet (called p2) when the position of p1 is the position of p2.
the verb to be proximate to means the proximity relation.
nominal proximity relates a planet (called p) to a number (called pos) when the position of p is pos.
the verb to be nominally proximate to means the nominal proximity relation.

to decide which list of planets is the planets at position (pos - a number):
decide on the list of planets nominally proximate to pos.

to decide which list of planets is the planets at the position of (p - a planet):
decide on the list of planets proximate to p.

Obligatory test room is a room.

when play begins:
say "[the planets at position 3].";
say "[the planets at the position of Mars].".``````