A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.wolfram.com/language/fast-introduction-for-programmers/en/patterns/ below:

Wolfram Language Fast Introduction for Programmers

Patterns | Wolfram Language Fast Introduction for Programmers WOLFRAM Products

More mobile apps

Core Technologies of Wolfram Products Deployment Options From the Community Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

WolframConsulting.com

Wolfram Solutions

More Wolfram Solutions

Wolfram Solutions For Education

More Solutions for Education

Learning & Support Get Started More Learning Grow Your Skills Tech Support Company Work with Us Educational Programs for Adults Educational Programs for Youth Read Educational Resources Wolfram Initiatives Events Wolfram|Alpha Wolfram Cloud Your Account Search Navigation Menu The Wolfram Language:
Fast Introduction for Programmers
Show additional notes for:
All sections  Get Started Patterns Video Version

Notes for Java programmers:

The Wolfram Language's pattern language lets you describe patterns for arbitrary symbolic structures, allowing powerful regex-like manipulation to be generalized to any expression and any form of data.

Notes for Python programmers:

The Wolfram Language's pattern language lets you describe patterns for arbitrary symbolic structures, allowing powerful regex-like manipulation to be generalized to any expression and any form of data.

Patterns stand for classes of expressions. The basic pattern construct _ (pronounced "blank") stands for any expression.

Find cases in a list matching the pattern f[_]:

In[1]:= Out[1]=

x_ (short for x:_) stands for a pattern whose value will be named x:

In[2]:= Out[2]=

/. means "replace everywhere":

In[3]:= Out[3]=

Notes for Java programmers:

The sort of structural metaprogramming shown here is unique to the Wolfram Language's symbolic structure.

Notes for Python programmers:

The structural metaprogramming shown here, which treats code and data in the same way, is unique to the Wolfram Language's symbolic structure.

__ ("double blank") stands for any sequence of expressions:

In[1]:= Out[1]=

a | b | c stands for a, b or c:

In[1]:= Out[1]=

Notes for Java programmers:

This usage of | resembles Java's regex notation, although in Java | can also indicate a bitwise OR.

Notes for Python programmers:

| is used in Wolfram Language patterns similarly to its use in Python's regular expressions. However, in the Wolfram Language, | works for any type of symbolic pattern matching, not just for strings.

It works in heads too:

In[2]:= Out[2]=

_h stands for any expression with head h:

In[1]:= Out[1]=

:> is a delayed rule—the analog of := for a rule.

QUICK REFERENCE: Operations Involving Patterns


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4