Identity¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Identity[expr]
gives expr unchanged (the identity function).
Examples (6)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (3)¶
In[1]:= Identity[x]
Out[1]= x
In[2]:= Identity[1 + 2]
Out[2]= 3
In[3]:= Map[Identity, {a, b, c}]
Out[3]= {a, b, c}
Applications (3)¶
Returns its argument unchanged
Its argument is evaluated normally first
The identity function is handy as a default callback
Implementation notes¶
builtin_identity (src/core.c) is the one-argument identity: it returns a copy of its single argument unchanged, or NULL for any other arity.
Attributes: Protected.
References¶
- Source:
src/core.c - Specification:
docs/spec/builtins/expression-information.md - Tests:
tests/test_eval.c - Tests:
tests/test_repl_hooks.c - Tests:
tests/test_sequence.c
Notes & additional examples¶
Notes¶
Identity[expr] returns expr unchanged. It takes exactly one argument; any other arity
is left unevaluated. Having no held attributes, it evaluates its argument through the
normal pipeline before returning it, so Identity[1 + 1] is 2.
It is most useful as a neutral function argument ā a do-nothing callback where some transformation is expected.