3 ms·
Where did you get that definition? "function that takes one argument and returns one value of the same type" is the identity function.
by mrkeen 10mo ago
Where did you get that definition?
"function that takes one argument and returns one value of the same type" is the identity function.
- epolanski 10mo agoIdentity function returns the same _value_. If it's only the same _type_, but the value is not the same, then it's an endomorphism. The function definitions look the same `a -> a`. string reversal, integer negation or toUpperCase are classical examples of endomorphisms. Identity is a specific case of endomorphism.
- mrkeen 10mo agostring reversal, integer negation or toUpperCase are classical examples of functions which will not compile as `a -> a` The function which will compile as `a -> a` is the identity function.
- epolanski 10mo agoThat's correct, but I'm not sure how it relates to my comment as I said that `a -> a` is just an endomorphism. identity, uppercase or negate are all endomorphisms, with identity being the only generic one.