Function Repository Resource:

PrioritizedSubstitutionSystem

Source Notebook

Compute the evolution of a substitution system where replacements are specified by a priority list

Contributed by: Stephen Wolfram and Jan Mangaldan

ResourceFunction["PrioritizedSubstitutionSystem"][rule,init,pos]

applies rule to init at the sequence of starting positions specifed by pos.

ResourceFunction["PrioritizedSubstitutionSystem"][rule,init,pos, "Compressed"]

drops steps at which no update occurred.

Details and Options

If there is no match at the specified positions, the string is left unchanged.

Examples

Basic Examples (1) 

Apply the substitution system's rules at the third position of the string, followed by the eighth:

In[1]:=
ResourceFunction[
 "PrioritizedSubstitutionSystem"][{"BA" -> "AB", "BB" -> "AA"}, "AABAABABBBA", {3, 8}]
Out[1]=

Scope (4) 

Use a list of rules and a list of positions:

In[2]:=
ResourceFunction[
 "PrioritizedSubstitutionSystem"][{"BA" -> "AB", "BB" -> "AA"}, "BBBAAAB", {4, 1, 3, 2, 1, 7, 2}]
Out[2]=

Use a single rule:

In[3]:=
ResourceFunction["PrioritizedSubstitutionSystem"][
 "BA" -> "AB", "BBBAAAB", {4, 1, 3, 2, 1, 7, 2}]
Out[3]=

Use a single position:

In[4]:=
ResourceFunction["PrioritizedSubstitutionSystem"][
 "BA" -> "AB", "BBBAAAB", 3]
Out[4]=

Return a compressed version:

In[5]:=
ResourceFunction[
 "PrioritizedSubstitutionSystem"][{"BA" -> "AB", "BB" -> "AA"}, "BBBAAAB", {1, 7, 2, 4, 1, 3, 2, 1, 7, 2}, "Compressed"]
Out[5]=

Version History

  • 1.0.0 – 18 March 2020

License Information