# How to insert a function into OptionsPattern?

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}]] :=
Grid[l,
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]


Or even this:

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


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.

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)?

-
This is because You are creating Frame independly of FrameStyle. You can use , FrameStyle -> Transparent –  Kuba Jul 18 '13 at 9:14
@Kuba I don't understand. Since in the normal case, I want to show the frame not make it transparent. –  luyuwuli Jul 18 '13 at 9:19
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, ... –  Kuba Jul 18 '13 at 9:24
@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. –  luyuwuli Jul 18 '13 at 9:34
Why it is not consistent? –  Kuba Jul 18 '13 at 9:37