I’ve written a function TableauForm to draw a standard Young Tableau. This problem is related to this one, however, the difficulty is that, a function has to be applied to the list in my case.

This is my first version code:

TableauForm [l : {{__} ..}, opts : OptionsPattern[{Alignment -> {Center, Center},FrameStyle -> Thin, Grid}]] := 
  Frame -> {None, None, 
    Thread@Rule[Flatten[Function[{a, b}, {a, #} & /@ b] @@@ Transpose[{Range@Length@l, Range /@ Length /@ l}], 1], True]}, 
  Alignment -> OptionValue[Alignment], FrameStyle -> OptionValue[FrameStyle]];

The function works well when evaluate this:

youngTableau = {{1, 2, 3}, {4}};
TableauForm [youngTableau]

first output

Or even this:

TableauForm [youngTableau, FrameStyle -> {Red, Thin}]

second output

But the flaw is that if someone doesn’t wants to show the lines (regardless of such a strange usage of this function) and evaluate this

TableauForm [youngTableau, Frame->None]

The output will still draw up the lines just like the first one.

first output

I’ve put the drawing function into the OptionsPattern, but only make it worse

TableauForm [l : {{__} ..}, opts : OptionsPattern[{Alignment -> {Center, Center}, 
    Frame -> {None, None, (Thread@ Rule[Flatten[Function[{a, b}, {a, #} & /@ b] @@@ Transpose[{Range@Length@#, Range /@ Length /@ #}], 1], True] &)},FrameStyle -> Thin, Grid}]] := 
  Grid[l, Frame -> OptionValue[Frame],Alignment -> OptionValue[Alignment],FrameStyle -> OptionValue[FrameStyle]];

Now evaluating TableauForm[youngTableau] will give a table with empty frame.

To sum up and put the problem into another way, how to write a function sharing the same OptionsPattern with Grid only changing some default settings? (Note that some default settings may be a function of the parameters.) Is it possible to put a function into OptionsPattern, or are there any other ways to do this(plot a Young Tableau)?

  • $\begingroup$ This is because You are creating Frame independly of FrameStyle. You can use , FrameStyle -> Transparent $\endgroup$ – Kuba Jul 18 '13 at 9:14
  • $\begingroup$ @Kuba I don't understand. Since in the normal case, I want to show the frame not make it transparent. $\endgroup$ – luyuwuli Jul 18 '13 at 9:19
  • $\begingroup$ There is also no options connected to Frame in your OptionsPattern, add , Frame -> Automatic, to it and add the following to the body: Frame -> If[OptionValue[Frame] =!= Automatic, OptionValue[Frame], {None, None, ... $\endgroup$ – Kuba Jul 18 '13 at 9:24
  • $\begingroup$ @Kuba Yes,this would work in this particular question. (Actually I've tried If[OptionValue[Frame] =!= None, ...,but my trial is not as good as yours)But the handling is not consistent with FrameStyle or others. And when applied to other functions with default settings Automatic,this solution will have to change again. $\endgroup$ – luyuwuli Jul 18 '13 at 9:34
  • $\begingroup$ Why it is not consistent? $\endgroup$ – Kuba Jul 18 '13 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.