sirain
sirain

Reputation: 1168

Is there a formal name for functions, whose return type is the type of their argument?

I am looking for a name to describe unary functions with the same return type as their argument. E.g.

int addOne(int arg) { return arg + 1; }

but not the following function

double divideBy2(int arg) { return ((double)arg) / 2.0; }

Upvotes: 1

Views: 86

Answers (1)

Guy Coder
Guy Coder

Reputation: 24976

When looking for names of functions in Computer Science related to Math, it is often helpful to think in terms of Math. So in Math your question would be

Need the type of function that has the same domain and codomain.

That would be an Endomorphism

From Wikipedia

In mathematics, an endomorphism is a morphism from a mathematical object to itself.

Upvotes: 4

Related Questions