Is there an identity function in Elixir?
@focused is correct - 1.10-dev has added the identity function.
Documentation
Old Answer:
No such function has been predefined (at least that I'm aware of). It can trivially be written as you've done in your question, or more succinctly as &(&1)
.
Function.identity/1
has been added to Elixir v1.10.0-dev recently:
Commit
Usage example:
Enum.map([1, 2, 3, 4], &Function.identity/1)