maxitg / SetReplace

C++/Wolfram Language package for exploring set and graph rewriting systems
MIT License
219 stars 44 forks source link

MultisetSubstitutionSystem: allow patterns like {a__, b__} to be matched multiple times #638

Closed maxitg closed 3 years ago

maxitg commented 3 years ago

Changes

Examples

In[] := #["ExpressionsEventsGraph", VertexLabels -> Automatic] &@
 SetReplaceTypeConvert[{WolframModelEvolutionObject, 2}]@
  GenerateMultihistory[
    MultisetSubstitutionSystem[{a__, b__} /; OrderedQ[{a, b}] :> {{a}, {b}}], {"MaxGeneration" -> 1,
     "MinEventInputs" -> 3, "MaxEventInputs" -> 3},
    None, {"InputCount", "SortedInputTokenIndices", "InputTokenIndices", "RuleIndex"}, {}][{1, 2, 3}]
image

This change is Reviewable

maxitg commented 3 years ago

I fixed the memory leak, so it's ready for review now. I ended up using @taliesinb's suggestion about Data`UnorderedAssociation from a previous PR after all. It turned out, not only it has a better API, but it is more reliable as well.