Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

PatternMatcher

Guides

  • A Virtual Machine for the Pattern Matcher

Symbols

  • CompilePatternToBytecode
  • CreatePatternMatcherVirtualMachine
  • PatternBytecodeDisassemble
  • PatternBytecodeInformation
  • PatternBytecode
  • PatternBytecodeQ
  • PatternMatcherEnableTrace
  • PatternMatcherExecute
  • PatternMatcherMatch
  • PatternMatcherMatchQ
  • PatternMatcherReplace
  • PatternMatcherStep
  • PatternMatcherTraceEnabled
  • PatternMatcherTraceEnabledQ
  • PatternMatcherVirtualMachine
  • PatternToMatchFunction
DanielS`PatternMatcher`
PatternMatcherExecute
​
PatternMatcherExecute
[vm,expr]
runs a pattern matching virtual machine
vm
on the expression
expr
and returns the result along with execution metadata.
​
​
PatternMatcherExecute
[patt,expr]
automatically compiles
patt
to PatternBytecode, creates a virtual machine, and matches
expr
.
​
Details and Options
Examples  
(4)
Basic Examples  
(1)
Match a simple literal pattern:
In[1]:=
PatternMatcherExecute
[5,5]
Out[1]=
ResultTrue,CyclesExecuted6,Bindings
Match a pattern with a blank:
In[2]:=
PatternMatcherExecute
[_Integer,42]
Out[2]=
ResultTrue,CyclesExecuted6,Bindings
Match a pattern with a named variable:
In[3]:=
PatternMatcherExecute
[{x_,x_},{5,5}]
Out[3]=
ResultTrue,CyclesExecuted22,BindingsGlobal`x5
Match fails when elements differ:
In[4]:=
PatternMatcherExecute
[{x_,x_},{5,10}]
Out[4]=
ResultFalse,CyclesExecuted19,Bindings
Match with head constraints:
In[5]:=
PatternMatcherExecute
[f[_Integer,_String],f[42,"text"]]
Out[5]=
ResultTrue,CyclesExecuted18,Bindings
Match using alternatives in the pattern:
In[6]:=
PatternMatcherExecute
[x_Integer|x_Real,314]
Out[6]=
ResultTrue,CyclesExecuted10,BindingsGlobal`x314
In[7]:=
PatternMatcherExecute
[x_Integer|x_Real,3.14]
Out[7]=
ResultTrue,CyclesExecuted14,BindingsGlobal`x3.14
Scope  
(2)

Properties & Relations  
(1)

SeeAlso
PatternMatcherVirtualMachine
 
▪
PatternBytecode
 
▪
PatternMatcherMatchQ
 
▪
PatternMatcherReplace
 
▪
CreatePatternMatcherVirtualMachine
 
▪
CompilePatternToBytecode
 
▪
PatternMatcherEnableTrace
 
▪
PatternMatcherTraceEnabledQ
RelatedGuides
▪
A Virtual Machine for the Pattern Matcher
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com