For example, Haskell
has the id
function, Julia has the identity
function, and many questions on SO deal with the identity function. (I suppose in Python you can do lambda x:x
)
I've been busting my brain trying to think of a use case for this function; and I've failed.
What is the purpose of the identity function, and what are its common use-cases?
id
composition.
is so lonely. Together they are a monoid:id . f == f == f . id
,f . (g . h) == (f . g) . h
. So you will seeid
used in cases where.
is used. – Follicleidentity
in Julia. – Leaden