Replace
and ReplaceAll
apply rules only once, so multiple (redundant) rules can be given as input and the first instance of a rule is the only one that is applied.
How can I go about creating a function simplifyRules
that can be given a list of rules and a relevant function (Replace, ReplaceAll, ReplaceRepeated, etc.) which returns a modified rules list without rules which are not applied by the function?
For example:
rules = FilterRules[{ImageSize->{Automatic, 300}, Scrollbars->{False, True}}~Join~Options[Pane], Options[Pane]];
simplifyRules[rules,ReplaceAll]
(* {ImageSize->{Automatic,300},
Scrollbars->{False,True},
Alignment->{Automatic,Automatic},
Appearance->Automatic,
AppearanceElements->Automatic,
BaselinePosition->Automatic,
BaseStyle->{},
ContentPadding->True,
DefaultBaseStyle->Pane,
Enabled->Automatic,
FrameMargins->Automatic,
ImageMargins->0,
ImageSizeAction->Automatic,
ScrollPosition->{0,0},
StripOnInput->False} *)
Merge[ First ]
$\endgroup$