"set-theory" class

5 次查看(过去 30 天)
John Pryce
John Pryce 2019-9-6
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 个评论
per isakson
per isakson 2019-9-7
Did you search the File Exchange ?
John Pryce
John Pryce 2019-9-9
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by