"set-theory" class

조회 수: 5 (최근 30일)
John Pryce
John Pryce 2019년 9월 6일
댓글: John Pryce 2019년 9월 9일
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