Function Repository Resource:

RandomSubstitutionSystemRule

Source Notebook

Generate a random string substitution rule

Contributed by: Stephen Wolfram

ResourceFunction["RandomSubstitutionSystemRule"][sig,k]

generates a random string substitution rule with signature sig and up to k distinct elements.

Details and Options

The signatures are of the form {lhs1rhs1,lhs2rhs2,}.
Successive letters of the alphabet are used to indicate elements.

Examples

Basic Examples (2) 

Generate a random string substitution system rule:

In[1]:=
ResourceFunction[
 "RandomSubstitutionSystemRule"][{2 -> 4, 5 -> 1, 3 -> 5}, 2]
Out[1]=

Generate two rules, with 3 distinct elements in each case:

In[2]:=
Table[ResourceFunction[
  "RandomSubstitutionSystemRule"][{2 -> 4, 5 -> 1, 3 -> 5}, 3], 2]
Out[2]=

Scope (2) 

Generate a single substitution system rule:

In[3]:=
ResourceFunction["RandomSubstitutionSystemRule"][4 -> 3, 4]
Out[3]=

Generate multiple substitution system rules:

In[4]:=
ResourceFunction["RandomSubstitutionSystemRule"][{4 -> 3, 1 -> 2}, 4]
Out[4]=

Version History

  • 1.0.0 – 25 September 2020

Related Resources

License Information