FHIR Chat · supersetOf · fhirpath

Stream: fhirpath

Topic: supersetOf


view this post on Zulip Paul Lynch (Aug 24 2018 at 22:15):

The description for supersetOf contains the following paragraph:

"Conceptually, this function is evaluated by testing each element in the other collection for membership in the input collection, with a default of false. This means that if the input collection is empty ({ }), the result is false, otherwise if the other collection is empty ({ }), the result is true."

Some questions:

1) Are paragraphs like this that are introduced by "conceptually" a part of the requirements, or merely helpful explanatory text?

2) In the first sentence, why would the default not be true, just as it is for subsetOf? In my code I am setting the default to true and then exiting the comparison loop as soon as it finds an element of the "other" collection that is not present in the input collection. It is actually the same code as for subsetOf, just that the input and other collections are swapped.

3) If both the input and other collections are empty, should it not be true that "input" is a superset of "other" (as in mathematics)? Usually if two sets are equal, they are both supersets and subsets of one another. Yet the second sentence here says the return should be false if the input collection is empty. I suspect there was an editing mistake from the description of subsetOf.

view this post on Zulip Bryn Rhodes (Aug 26 2018 at 21:30):

Hi @Paul Lynch , you are correct, the text isn't quite right there. To answer the first question, the intent of the paragraph is to provide clarification, and yes, X.subsetOf(Y) should always be the same as Y.supersetOf(X) and if two sets are equal, they are both supersets and subsets of each other. So in the second paragraph, yes the default would be true, and if the _other_ collection is empty, the result is true, otherwise if the _input_ collection is empty, the result is false.

view this post on Zulip Paul Lynch (Aug 27 2018 at 15:41):

Thanks. Would it be helpful for me to open a GForge ticket for that edit?

view this post on Zulip Bryn Rhodes (Aug 29 2018 at 19:40):

I've made a note of it and plan to submit it as a ballot comment.


Last updated: Apr 12 2022 at 19:14 UTC