"set-theory" class

Has anyone implemented a class that implements sets, as in set theory, more neatly than MATLAB does at present?
Set operations to be infix, e.g. replace intersect(A,B) by A*B for members of this class.
I'm mainly interested in sets of text strings. Convenience means more to me than great efficiency so I'm happy if under the hood the objects are
  • cell arrays of char arrays like {'pqr','c123','a'}
  • or arrays of strings like ["pqr","c123","a"]
but normalised to lexicographic order.

3 comentarios

David K.
David K. el 6 de Sept. de 2019
If no one says that they have, it actually looks pretty simple to do yourself if you use this help page as a reference. Especially if all you want to do is basically wrap up functions matlab already has.
per isakson
per isakson el 7 de Sept. de 2019
Did you search the File Exchange ?
John Pryce
John Pryce el 9 de Sept. de 2019
Yes, I have now done it myself. I decided
  • They are string arrays "under the hood".
  • intersect(A,B) becomes A&B
  • union(A,B) becomes A|B
  • setdiff(A,B) becomes A\B
  • setxor(A,B) becomes A~=B
thus overloading respectively and(), or(), mldivide() and ne()
A few other methods such as card() for the cardinality.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Preguntada:

el 6 de Sept. de 2019

Comentada:

el 9 de Sept. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by