OneIdentity

OneIdentity

is an attribute that can be assigned to a symbol f to indicate that f[x], f[f[x]], etc. are all equivalent to x for the purpose of pattern matching.

Details

Examples

open allclose all

Basic Examples  (1)

The pattern matches, because Times has attribute OneIdentity:

Any function with attribute OneIdentity will match:

Properties & Relations  (2)

OneIdentity allows defaults to apply to expressions that do not involve Times at all:

For Flat functions, any sequence of arguments will match Blank:

When f is both Flat and OneIdentity, f[x_] will attempt to match x_ to a rather than f[a]:

Possible Issues  (1)

In order for f[a] to match a, you must use a pattern that includes Optional:

Similarly, the following pattern fails because f has no defined defaults:

Defining a default will resolve this issue:

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

Text

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

CMS

Wolfram Language. 1988. "OneIdentity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/OneIdentity.html.

APA

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

BibTeX

@misc{reference.wolfram_2024_oneidentity, author="Wolfram Research", title="{OneIdentity}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/OneIdentity.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_oneidentity, organization={Wolfram Research}, title={OneIdentity}, year={2003}, url={https://reference.wolfram.com/language/ref/OneIdentity.html}, note=[Accessed: 03-December-2024 ]}