-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathSetReplaceFixedPointList.m
35 lines (27 loc) · 1.18 KB
/
SetReplaceFixedPointList.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Package["SetReplace`"]
PackageImport["GeneralUtilities`"]
PackageExport["SetReplaceFixedPointList"]
(* Same as SetReplaceFixedPoint, but returns all intermediate steps. *)
SetUsage @ "
SetReplaceFixedPointList[set$, {input$1 -> output$1, input$2 -> output$2, $$}] performs SetReplace repeatedly until \
no further events can be matched, and returns the list of all intermediate sets.
";
Options[SetReplaceFixedPointList] = {
Method -> Automatic,
TimeConstraint -> Infinity,
"EventOrderingFunction" -> Automatic};
SyntaxInformation[SetReplaceFixedPointList] = {
"ArgumentsPattern" -> {set_, rules_, OptionsPattern[]},
"OptionNames" -> Options[SetReplaceFixedPointList][[All, 1]]};
SetReplaceFixedPointList[args___] := 0 /;
!Developer`CheckArgumentCount[SetReplaceFixedPointList[args], 2, 2] && False;
SetReplaceFixedPointList[set_, rules_, o : OptionsPattern[]] /;
recognizedOptionsQ[expr, SetReplaceFixedPointList, {o}] := ModuleScope[
result = Check[
setSubstitutionSystem[rules, set, <||>, SetReplaceFixedPointList, False, o]
,
$Failed
];
If[result === $Aborted, result, result["SetAfterEvent", #] & /@ Range[0, result["EventsCount"]]] /;
result =!= $Failed
];