Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <|"x"->{... big list ...},....|>
- x:[xMinValue,xMaxValue] (where xMinValue=Min[{..Big List...}]...)
- Format[f[x_?ListQ]] :=
- "f[x], x:[" <> ToString[Min[x]] <> ", " <> ToString[Max[x]] <> "]"
- In[2]= f[Range[20]]]
- Out[2]= f[x], x:[1, 20]
- In[3]= Format[<|"x"->x_?ListQ|>] :=
- "x:[" <> ToString[Min[x]] <> ", " <> ToString[Max[x]] <> "]"
- Unprotect[Association];
- format[x_List] := "<< Very long list that we do not want to see, honestly. >>";
- format[x_] := x;
- Association /: Format[a_Association] :=
- Row[{"[LeftAssociation]",
- Sequence @@
- Riffle[Rule @@@ Transpose[{Keys[a], format /@ Values[a]}], ", "],
- "[RightAssociation]"}]
- Protect[Association];
- Association["Bli" -> 1, "Bla" -> Association["Blabla" -> {2, 3}], "Blubb" -> {4, 5}]
- MyAssocationQ[assoc_] := MatchQ[assoc, <|"x" -> _?ListQ|>]
- MyAssocationQ[<|"x" -> {-5, 2, 9}|>]
- MyAssocationQ[2017]
- MyAssocationQ[<|"x" -> {-5, 2, 9},"y"->1|>]
- Unprotect[Association];
- Association /: Format[assoc_Association /; MyAssocationQ[assoc]] :=
- "x:[" <> ToString[Min[assoc["x"]]] <> ", " <>
- ToString[Max[assoc["x"]]] <> "]";
- Protect[Association];
- In[]= <|"x" -> {-5, 2, 9}|>
- In[]= <|"x" -> {-5, 2, 9}, "y" -> 5|>
Add Comment
Please, Sign In to add comment