Mathematica: Pattern Matching

Favorite Article   


Rules

  • lhs?rhs (Rule) — representation of replacement rule
  • expr/.rules (ReplaceAll) — apply replacement rules to an expression
  • RuleDelayed(:>)  
  • ReplaceRepeated(//.)    
  • Condition(/;)  
     

Patterns

  • x_ — any expression, named 
  • x__ — sequence of expressions
  • a|b|c — alternative forms
  • Repeated(..)  
  • Except    
  • Longest    
  • Shortest  
     

Pattern Matching Functions

  • Cases — elements of a list or expression matching a given pattern
  • Position    
  • MemberQ    
  • MatchQ   
  • Count   
  • DeleteCases
     

Assignments

  • lhs=rhs, lhs:=rhs — make assignments for arbitrary patterns

 

Referenced from: Reference.wolfram.com

 

19588
1/10/2018 8:02:22 AM