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`
CreatePatternMatcherVirtualMachine
​
CreatePatternMatcherVirtualMachine
[bc]
creates a virtual machine instance for executing the given
PatternBytecode
bc
.
​
​
CreatePatternMatcherVirtualMachine[patt]
compiles
patt
into a
PatternBytecode
object before creating the virtual machine.
​
Details and Options
Examples  
(4)
Basic Examples  
(2)
Compile a pattern to bytecode:
In[1]:=
bc=
CompilePatternToBytecode
[_Integer]
Out[1]=
PatternBytecode
Pattern:
_Integer
Expr registers count: 1
Bool registers count: 1
Instruction count: 9

Create a virtual machine from the generated bytecode:
In[2]:=
vm=
CreatePatternMatcherVirtualMachine
[bc]
Out[2]=
PatternMatcherVirtualMachine
Initialized: True
Halted: False
Program counter: 0
Cycles: 0

Execute the virtual machine against different expressions:
In[3]:=
PatternMatcherExecute
[vm,42]
Out[3]=
ResultTrue,CyclesExecuted6,Bindings
In[4]:=
PatternMatcherExecute
[vm,3.14]
Out[4]=
ResultFalse,CyclesExecuted4,Bindings
​
Create a virtual machine for a pattern with variable bindings:
In[1]:=
bc=
CompilePatternToBytecode
[f[x_,x_]];​​vm=
CreatePatternMatcherVirtualMachine
[bc]
Out[1]=
PatternMatcherVirtualMachine
Initialized: True
Halted: False
Program counter: 0
Cycles: 0

Execute the virtual machine:
In[2]:=
PatternMatcherExecute
[vm,f[5,5]]
Out[2]=
ResultTrue,CyclesExecuted22,BindingsGlobal`x5
Scope  
(1)

Properties & Relations  
(1)

SeeAlso
PatternMatcherVirtualMachine
 
▪
PatternMatcherExecute
 
▪
PatternMatcherMatchQ
 
▪
PatternMatcherReplace
 
▪
CompilePatternToBytecode
 
▪
PatternBytecode
RelatedGuides
▪
A Virtual Machine for the Pattern Matcher
""

© 2026 Wolfram. All rights reserved.

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