# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Get an association of match positions to rule matches, sorted according to traversal scheme, for a combinator expression

Contributed by:
Wolfram Research

ResourceFunction["CombinatorMatches"][ gives an association of match positions to rule matches for | |

ResourceFunction["CombinatorMatches"][ gives an association of match positions to rule matches for |

ResourceFunction["CombinatorMatches"] finds rule matches, instances where the *rules* can be applied to parts of *cmb*. The keys of the association are the positions of the rule matches within *cmb*. The values of the association refer to the index in *rules* of the applicable combinator transformations.

The argument *cmb* must be given as a combinator expression in nested bracket form.

In *scheme*, both direction ("Leftmost" or "Rightmost") and depth order ("Outermost" or "Innermost") must be specified, in order of their priority as sorting criteria.

The *scheme*, which is a list, can include an optional third element, specified as an integer number or Infinity, that indicates how many elements from the sorted *list* should be given.

The combinator transformations of interest should be given as a list of Rule or RuleDelayed elements in *rules*.

ResourceFunction["CombinatorMatches"] takes the following option:

SKGlyphs | {CombinatorS,CombinatorK} | symbols used to specify default transformation rules |

Find the leftmost-outermost-sorted matches of the combinator expression in the **S****K** basis:

In[1]:= |

Out[1]= |

Find the leftmost-outermost-sorted matches of the combinator expression in the **S****K** basis:

In[2]:= |

Out[2]= |

Sort the **S****K** basis matches of the expression in outermost-leftmost order:

In[3]:= |

Out[3]= |

Choose the first two **S****K** basis matches of the expression from the innermost-rightmost evaluation order:

In[4]:= |

Out[4]= |

Find **K** combinator matches of an expression in rightmost-outermost order:

In[5]:= |

Out[5]= |

Group the match positions by the corresponding rule:

In[6]:= |

Out[6]= |

Extract rule-matched subexpressions of a combinator expression:

In[7]:= |

Out[7]= |

- 1.0.1 – 05 December 2020
- 1.0.0 – 04 December 2020

This work is licensed under a Creative Commons Attribution 4.0 International License