ContainsAll should always return True with empty lists

I noticed that the very useful ContainsAll function returns false when I check if a list contains an empty list.

This is demonstrable with simple formulas:

  • list('a', 'b', 'c').containsall(list('a', 'b')) returns true.
  • list('a', 'b', 'c').containsall(list('a')) returns true.
  • list('a', 'b', 'c').containsall(list()) returns false.

I feel like the last item should return true as well, since the empty set is a subset of any set.

I realize that this behavior is bypassable if I include a check for emptiness in my formulas, like this:

  • or(list().isblank(), list('a', 'b', 'c').containsall(list()))

But I think that eventually this will have to be rectified.
I tried to search the forums here before writing the topic, but please let me know if I missed something :slightly_smiling_face:


Dear @John_Choi, great having you in the community :handshake:

Thanks explaining in detail your approach / understanding

In the help section for formulas is explained the conditions / syntax:


Hi @John_Choi,
I second @Jean_Pierre_Traets to welcome you to this community!

This is my own interpretation so, please, take it as it is (@Codans please correct me).
You are formally right, and I would have expected the same behaviour.
However, I think that Coda is mainly aimed at people who don’t necessarily have a formal programming background and some of their implementations choices are more prone to a better intuition rather than formality (e.g. also 1-indexed arrays).

Said that, your workaround is a good way to overcome with that.