A RetroSearch Logo

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

Search Query:

Showing content from http://reference.wolfram.com/language/ref/PatternTest.html below:

PatternTest—Wolfram Documentation

WOLFRAM Consulting & Solutions

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

WolframConsulting.com

p?test

is a pattern object that stands for any expression that matches p, and on which the application of test gives True.

Details Examplesopen all close all Basic Examples  (3)

Find cases of any expression that satisfies the NumberQ test:

Test whether a list has only positive elements:

Create a definition that only applies to numeric arguments:

Scope  (6)

Replace negative numbers with zero:

Find elements in a list that are divisible by 7:

Elements that are divisible by both 5 and 7:

Elements that are divisible by either 5 or 7:

Create a function that only evaluates when given a non-negative number and a prime:

Create a function that only evaluates for negative primes:

Use PatternTest on a complex pattern:

Search for numbers without allowing expressions to evaluate:

Just using NumberQ would allow each element to evaluate:

Properties & Relations  (2)

PatternTest applies test functions to patterns, which need not have names:

Condition evaluates a Boolean expression on named parts of a pattern:

Use Except to effectively negate PatternTest:

Possible Issues  (1)

PatternTest evaluates potential matches that are a part of a held expression:

Due to normal evaluation rules, expressions may evaluate before being examined by the test function:

Use the three-argument form of Function or write the pattern using Condition to prevent this:

History

Introduced in 1988 (1.0)

Wolfram Research (1988), PatternTest, Wolfram Language function, https://reference.wolfram.com/language/ref/PatternTest.html. Text

Wolfram Research (1988), PatternTest, Wolfram Language function, https://reference.wolfram.com/language/ref/PatternTest.html.

CMS

Wolfram Language. 1988. "PatternTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PatternTest.html.

APA

Wolfram Language. (1988). PatternTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PatternTest.html

BibTeX

@misc{reference.wolfram_2025_patterntest, author="Wolfram Research", title="{PatternTest}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/PatternTest.html}", note=[Accessed: 17-August-2025]}

BibLaTeX

@online{reference.wolfram_2025_patterntest, organization={Wolfram Research}, title={PatternTest}, year={1988}, url={https://reference.wolfram.com/language/ref/PatternTest.html}, note=[Accessed: 17-August-2025]}


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