I have some assocations, containing a lot of data, lets say something like
<|"x"->{... big list ...},....|>
I would like to print these associations in a convenient and concise form, let's say:
x:[xMinValue,xMaxValue] (where xMinValue=Min[{..Big List...}]...)
For this purpose my idea was to use the Format
command. Reading the official mma doc I have this example:
Format[f[x_?ListQ]] := "f[x], x:[" <> ToString[Min[x]] <> ", " <> ToString[Max[x]] <> "]"
For example:
f[Range[20]]]
f[x], x:[1, 20]
However, and this is my problem, I have no success with Association
:
Format[<|"x"->x_?ListQ|>] := "x:[" <> ToString[Min[x]] <> ", " <> ToString[Max[x]] <> "]"
SetDelayed::write: Tag Association in MakeBoxes[Association[x_?ListQ],FormatType_] is Protected.
SetDelayed::write: Tag Association in Association[x_?ListQ] is Protected.
My question: how to define custom and pretty print of Association
?
Association
have the propertiyProtected
, so you have toUnprotect
them first. Second,Association
s are atomic. Hence, pattern matching withinAssociation
s does not work. $\endgroup$ – Henrik Schumacher Nov 23 '17 at 15:51