-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathSetReplaceList.m
36 lines (28 loc) · 1.11 KB
/
SetReplaceList.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
36
Package["SetReplace`"]
PackageImport["GeneralUtilities`"]
PackageExport["SetReplaceList"]
(* Same as SetReplace, but returns all intermediate steps in a List. *)
SetUsage @ "
SetReplaceList[set$, rules$, eventCount$] performs SetReplace eventCount$ times and returns the list of all \
intermediate results.
";
Options[SetReplaceList] = {
Method -> Automatic,
TimeConstraint -> Infinity,
"EventOrderingFunction" -> Automatic};
SyntaxInformation[SetReplaceList] = {
"ArgumentsPattern" -> {set_, rules_, eventCount_, OptionsPattern[]},
"OptionNames" -> Options[SetReplaceList][[All, 1]]};
SetReplaceList[args___] := 0 /;
!Developer`CheckArgumentCount[SetReplaceList[args], 2, 3] && False;
SetReplaceList[set_, rules_, events : Except[_ ? OptionQ] : 1, o : OptionsPattern[]] /;
recognizedOptionsQ[expr, SetReplaceList, {o}] :=
ModuleScope[
result = Check[
setSubstitutionSystem[rules, set, <|$maxEvents -> events|>, SetReplaceList, False, o]
,
$Failed
];
If[result === $Aborted, result, result["SetAfterEvent", #] & /@ Range[0, result["EventsCount"]]] /;
result =!= $Failed
];