<property> IN <list> feature

(imported topic written by gjeremia91)

NOTE

Jesse has posted below a much simpler way that I’d not previously used, Thanks Jesse !. Still convert your list into a set and then use the "contains " operator.

I thought I’d share another useful piece of relevance, hopefully it will help others. If it doesn’t help others then it will serve as somewhere I can find when I’ve forgotten how to do it myself.

Sometimes we just want to use relevance to see if some property exists in a list, like

IN

e.g.

lines of whose (it IN (“line 1”;“line 2”))

or

names of fixlets whose (id of it IN (1;5;7;54))

or simply:

1 IN (1;3;5;7)

In other words, we have a list (probably from some other piece of relevance) and we want to see if a property of an object matches a member of that list.

Lots of relevance can be written to have many OR statements, but that’s not always possible if you are getting your list from elsewhere, and it is not possible in the language today using a straight forward “IN” syntax, but here is what I use to achieve the same thing. The general format is:

(set of (<list>) * it = it) of (set of (<property>))

e.g.

does 1 exist in the list 1;3;5;7?

1 IN (1;3;5;7) becomes (set of (1;3;5;7) * it = it) of (set of (1))

names of fixlets that have an ID that is 1 or 5 or 7 or 54 (i.e. from the list 1;5;7;54)

names of fixlets whose (id of it IN (1;5;7;54)) becomes names of fixlets whose ((set of (1;5;7;54) * it = it) of (set of (id of it)) )

what lines of the file match values from the list of “line 1”;“line 2”

lines of <file> whose (it IN (
"line 1";
"line 2")) becomes lines of <file> whose ( (set of (
"line 1";
"line 2") * it = it) of (set of (it)) )

(imported comment written by jessewk)

This is a lot simpler:

set of (1;3;5;7) contains 1

set of (names of bes fixlets) contains 
"name"

etc…

(imported comment written by gjeremia91)

Yes this is MUCH simpler, I had missed that from the very bottom of the String and String Set reference in the BigFix inspectors guide, so this page will still serve as a useful reference for me, lol