# A certain kind of Object Oriented functionality in Mathematica?

I'm looking to implement a certain aspect of object oriented programming in Mathematica. I've read a lot of the big threads where people have discussed different approaches to implement OO in Mathematica. One I particularly liked and have been using is what this author does: https://github.com/antononcube/MathematicaForPrediction/blob/master/Documentation/Implementation-of-Object-Oriented-Programming-Design-Patterns-in-Mathematica.pdf

However, I'm having trouble implementing a certain feature I'd like. I'm trying to use objects to model Young Tabloids. If you haven't seen them, a Young Tableaux of shape $\lambda=(\lambda_1,\dots,\lambda_k)$ is essentially a set of $n=\lambda_1+\dots+\lambda_k$ boxes where row $i$ has $\lambda_i$ boxes, and we place the elements $\{1,\dots,n\}$ in the boxes. For example, here is a tableaux of shape $(3,3,2,1)$.

I'm specifically looking at tabloids, which are equivalence classes of tableaux in which two tableaux are the same if they have the same rows. For instance, the following two tableaux represent the same tabloid:

The basic code I'm using to represent these is things like:

tabloid[n_,d_]["data"[]] := d;
tabloid[n_,d_]["sortedData"[]] := Sort /@ d;
tabloid[n_,d_]["shape"[]] := Length /@ d;
tabloid[n_,d_]["entries"[]] := Sort[Flatten[d]];

t = tabloid[3,{{2,1},{3}}]


My problem is that I would like Mathematica to interpret tabloids by their equivalence class: that is, I would like Mathematica to treat tabloid[3,{{2,1},{3}}] as the same thing as tabloid[3,{{1,2},{3}}]. For instance, I'd like the output of

Union[{tabloid[3,{{1,2},{3}}], tabloid[3,{{2,1},{3}}]}]


to be

{tabloid[3,{{1,2},{3}}]}


Does anybody have any ideas how I can do this? I've gone as far as doing Unprotect[Equal] and redefining equality for things whose head is tabloid and it still didn't work how I'd like. Obviously I'd prefer to not have to do this anyways but it was just out of curiosity.

• Maybe OrderlessPatternSequence can do what you are looking for? – Sascha Jun 20 '16 at 15:50
• This seems like it could work. I need to define a group action on the tabloids, so I'll have to see if I can make the action work on one of these elements in particular. Thanks for the suggestion. – Alex Mathers Jun 20 '16 at 16:00
• Have you seen the Combinatorica implementation of Young tableaux, just in case? – J. M. will be back soon Jun 20 '16 at 16:28
• @J.M. no actually I had no idea that existed! – Alex Mathers Jun 20 '16 at 16:39