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`
PatternMatcherMatch
​
PatternMatcherMatch
[vm,expr]
test whether the expression
expr
matches the pattern specified by the virtual machine
vm
.
​
Details and Options
Examples  
(3)
Basic Examples  
(1)
Convert a pattern into bytecode object:
In[1]:=
patt=
CompilePatternToBytecode
[f[_]]
Out[1]=
PatternBytecode
Pattern:
f[_]
Bytecode:
TEST_LENGTH 1CHECK_ABORTGET_HEADPUSH_EXPR fSAMEQCHECK_ABORTGET_PART 1BLANK

The pattern bytecode can be used to create a virtual machine:
In[2]:=
vm=
CreatePatternMatcherVirtualMachine
[patt]
Out[2]=
PatternMatcherVirtualMachine
Halted: False
Program counter: 1
Stack: {}
Pattern bytecode: PatternBytecode
Pattern:
f[_]

Bound variables: 
Cycles: 0

Use the virtual machine to test whether an expression matches the pattern:
In[3]:=
PatternMatcherMatch[vm,f[1]]
Out[3]=
PatternMatcherVirtualMachine
Halted: True
Program counter: 9
Stack: {True}
Pattern bytecode: PatternBytecode
Pattern:
f[_]

Bound variables: 
Cycles: 8

The result of the matching will be the last value in the stack:
In[4]:=
TrueQ[Last[vm["Stack"]["Elements"]]]
Out[4]=
True
Scope  
(1)

Properties & Relations  
(1)

SeeAlso
PatternMatcherVirtualMachine
 
▪
PatternMatcherStep
 
▪
CreatePatternMatcherVirtualMachine
 
▪
PatternBytecode
 
▪
CompilePatternToBytecode
RelatedGuides
▪
The Pattern Matcher Virtual Machine
""

© 2026 Wolfram. All rights reserved.

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