# Why is an Identity function needed?

Today I came across the function Identity[x] in Mathematica (documentation). The example given in the documentation uses it in Map as follows

TableForm[Composition[Through, {Identity, Sqrt}] /@ {0, 1.0, 2.0, 3.0, 4.0}].

For me, I have always written such maps as

TableForm[Composition[Through, {#&, Sqrt}] /@ {0, 1.0, 2.0, 3.0, 4.0}]

Is there any real advantage (performance, memory usage, etc ..) for using Identity over a lambda function? Are there any examples where one is forced to actually use Identity? I am not sure I get the point of having this Identity function.

• One good reason for having a built-in, named Identity function is that it can be documented in same way as all the other named functions. – m_goldberg Aug 29 '15 at 13:27

There are subtle differences between #& and Identity.

If you pass more than one argument, Identity will complain and remain unevaluated, #& will just return the first argument.

Identity[x, y]
(* Identity::argx: Identity called with 2 arguments; 1 argument is expected. >> *)
(* Identity[x, y] *)

#&[x, y]
(* x *)

Also Identity is automatically simplified inside Composition and #& is not.

g @* Identity @* f
(* g @* f *)

g @* (#&) @* f
(* g @* (#1&) @* f *)
• What does this @* construct do? My Mathematica 9 doesn't understand it. – Ruslan Aug 29 '15 at 10:02
• @Ruslan @* is short form for Composition. – dionys Aug 29 '15 at 10:33
• @Ruslan. @* was introduced in V10 – m_goldberg Aug 29 '15 at 13:16