What is a term for a function that when called repeatedly, has the same effect as calling once?2019 Community Moderator ElectionWhat is a good alternative to the name variable for a language that only has immutable references or labels?What is the name for a NON-self-calling function?What is a widely accepted term for a string variable that would probably contain a file path and file name?Is it a good idea to provide different function signatures that do the same thing?Naming convention for classes that represents different versions of the same thingWhat is a term for iterating over many functions with the same input?Is there a commonly accepted name for functions that are only called in one other function?What is the term used to describe a function/method that modifies the object it's called on?For use once only functions extracted from a longer function, should the name be xxx1(),xxx2,… or relate to there task?What is a Function that Creates Functions Called?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Can I solder 12/2 Romex to extend wire 5 ft?

What is a term for a function that when called repeatedly, has the same effect as calling once?

Why are special aircraft used for the carriers in the United States Navy?

Is divide-by-zero a security vulnerability?

School performs periodic password audits. Is my password compromised?

Can the Shape Water Cantrip be used to manipulate blood?

Is every open circuit a capacitor?

PTIJ: What dummy is the Gemara referring to?

What is the meaning of "notice to quit at once" and "Lotty points”

PTIJ: Why can't I sing about soda on certain days?

Why did the Cray-1 have 8 parity bits per word?

How do we objectively assess if a dialogue sounds unnatural or cringy?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

How can I handle a player who pre-plans arguments about my rulings on RAW?

Should we avoid writing fiction about historical events without extensive research?

Where is the fallacy here?

How can neutral atoms have exactly zero electric field when there is a difference in the positions of the charges?

Was it really inappropriate to write a pull request for the company I interviewed with?

Is there a way to find out the age of climbing ropes?

When to use mean vs median

Is there a full canon version of Tyrion's jackass/honeycomb joke?

Why is it "take a leak?"

Relationship between the symmetry number of a molecule as used in rotational spectroscopy and point group



What is a term for a function that when called repeatedly, has the same effect as calling once?



2019 Community Moderator ElectionWhat is a good alternative to the name variable for a language that only has immutable references or labels?What is the name for a NON-self-calling function?What is a widely accepted term for a string variable that would probably contain a file path and file name?Is it a good idea to provide different function signatures that do the same thing?Naming convention for classes that represents different versions of the same thingWhat is a term for iterating over many functions with the same input?Is there a commonly accepted name for functions that are only called in one other function?What is the term used to describe a function/method that modifies the object it's called on?For use once only functions extracted from a longer function, should the name be xxx1(),xxx2,… or relate to there task?What is a Function that Creates Functions Called?










86















(Assuming a single-threaded environment)



A function that fulfills this criterion is:



bool MyClass::is_initialized = false;

void MyClass::lazy_initialize()

if (!is_initialized)

initialize(); //Should not be called multiple times
is_initialized = true;




In essence, I can call this function multiple times and not worry about it initializing MyClass multiple times



A function that does not fulfill this criterion might be:



Foo* MyClass::ptr = NULL;

void initialize()

ptr = new Foo();



Calling initialize() multiple times will cause a memory leak



Motivation



It would be nice to have a single concise word to describe this behavior so that functions that are expected to meet this criterion can be duly commented (especially useful when describing interface functions that are expected to be overridden)










share|improve this question



















  • 61





    To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

    – Jörg W Mittag
    2 days ago






  • 29





    Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

    – RemcoGerlich
    2 days ago






  • 11





    @dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

    – glglgl
    2 days ago






  • 16





    @glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

    – dotancohen
    2 days ago






  • 7





    @dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

    – Robert Harvey
    2 days ago
















86















(Assuming a single-threaded environment)



A function that fulfills this criterion is:



bool MyClass::is_initialized = false;

void MyClass::lazy_initialize()

if (!is_initialized)

initialize(); //Should not be called multiple times
is_initialized = true;




In essence, I can call this function multiple times and not worry about it initializing MyClass multiple times



A function that does not fulfill this criterion might be:



Foo* MyClass::ptr = NULL;

void initialize()

ptr = new Foo();



Calling initialize() multiple times will cause a memory leak



Motivation



It would be nice to have a single concise word to describe this behavior so that functions that are expected to meet this criterion can be duly commented (especially useful when describing interface functions that are expected to be overridden)










share|improve this question



















  • 61





    To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

    – Jörg W Mittag
    2 days ago






  • 29





    Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

    – RemcoGerlich
    2 days ago






  • 11





    @dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

    – glglgl
    2 days ago






  • 16





    @glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

    – dotancohen
    2 days ago






  • 7





    @dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

    – Robert Harvey
    2 days ago














86












86








86


5






(Assuming a single-threaded environment)



A function that fulfills this criterion is:



bool MyClass::is_initialized = false;

void MyClass::lazy_initialize()

if (!is_initialized)

initialize(); //Should not be called multiple times
is_initialized = true;




In essence, I can call this function multiple times and not worry about it initializing MyClass multiple times



A function that does not fulfill this criterion might be:



Foo* MyClass::ptr = NULL;

void initialize()

ptr = new Foo();



Calling initialize() multiple times will cause a memory leak



Motivation



It would be nice to have a single concise word to describe this behavior so that functions that are expected to meet this criterion can be duly commented (especially useful when describing interface functions that are expected to be overridden)










share|improve this question
















(Assuming a single-threaded environment)



A function that fulfills this criterion is:



bool MyClass::is_initialized = false;

void MyClass::lazy_initialize()

if (!is_initialized)

initialize(); //Should not be called multiple times
is_initialized = true;




In essence, I can call this function multiple times and not worry about it initializing MyClass multiple times



A function that does not fulfill this criterion might be:



Foo* MyClass::ptr = NULL;

void initialize()

ptr = new Foo();



Calling initialize() multiple times will cause a memory leak



Motivation



It would be nice to have a single concise word to describe this behavior so that functions that are expected to meet this criterion can be duly commented (especially useful when describing interface functions that are expected to be overridden)







naming functions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 16 hours ago









doubleYou

2,0411420




2,0411420










asked Mar 4 at 3:43









WoofasWoofas

814248




814248







  • 61





    To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

    – Jörg W Mittag
    2 days ago






  • 29





    Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

    – RemcoGerlich
    2 days ago






  • 11





    @dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

    – glglgl
    2 days ago






  • 16





    @glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

    – dotancohen
    2 days ago






  • 7





    @dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

    – Robert Harvey
    2 days ago













  • 61





    To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

    – Jörg W Mittag
    2 days ago






  • 29





    Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

    – RemcoGerlich
    2 days ago






  • 11





    @dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

    – glglgl
    2 days ago






  • 16





    @glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

    – dotancohen
    2 days ago






  • 7





    @dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

    – Robert Harvey
    2 days ago








61




61





To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

– Jörg W Mittag
2 days ago





To the close voter(s): while it is true that 99.999% (rough estimate) of all "name-that-thing" questions are off-topic because they don't have a single, correct, unambiguous, objective answer and the naming is purely subjective and opinion-based, this one does have a single, correct, unambiguous, objective answer, which was given by the OP himself.

– Jörg W Mittag
2 days ago




29




29





Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

– RemcoGerlich
2 days ago





Calling it multiple times does have an effect, as there could be other code that changed 'var' in between.

– RemcoGerlich
2 days ago




11




11





@dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

– glglgl
2 days ago





@dotancohen Q/A style self-answering is one of the key concepts on StackExchange.

– glglgl
2 days ago




16




16





@glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

– dotancohen
2 days ago





@glglgl: I agree, for questions with merit. What merit has this question? I'm seriously concerned that we'll start getting every CS 101 question asked and immediately answered by the OP, every single CS term asked and immediately defined by the OP, and every basic algorithm's pros and cons questioned then immediately answered by the OP (not necessarily this OP). Is that the site that we want softwareengineering.SE to be?

– dotancohen
2 days ago




7




7





@dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

– Robert Harvey
2 days ago






@dotancohen: To be honest, the top-voted answer doesn't have much merit. It would be better if the answer included examples illustrating why idempotence is important. This isn't Jeopardy.

– Robert Harvey
2 days ago











6 Answers
6






active

oldest

votes


















209














This type of function / operation is called Idempotent




Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.




In mathematics, this means that if f is idempotent, f(f(x)) = f(x), which is the same as saying ff = f.



In computer science, this means that if f(x); is idempotent, f(x); is the same as f(x); f(x);.



Note: These meanings seem different, but under the denotational semantics of state, the word "idempotent" actually has the same exact meaning in both mathematics and computer science.






share|improve this answer




















  • 7





    Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

    – Tezra
    2 days ago






  • 7





    @Tezra: Both definitions are acceptable.

    – Dietrich Epp
    2 days ago






  • 5





    Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

    – Jasper
    yesterday






  • 1





    @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

    – Dietrich Epp
    yesterday






  • 1





    @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

    – Tezra
    yesterday



















47














The precise term for this (as Woofas mentions) is idempotence. I wanted to add that while you could call your func1 method idempotent, you could not call it a pure function. The properties of a pure function are two: it must be idempotent and it must not have side effects, which is to say, no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams.



The reason I mention this is that a idempotent function with side effects is not good either, since technically idempotent refers to the return output of the function, and not to the side effects. So technically your func2 method is idempotent, as the output doesn't change according to the input.



You most likely want to specify that you want a pure function. An example of a pure function might be as follows:



int func1(int var)

return var + 1;



More reading can be found in the Wikipedia article "Pure function".






share|improve this answer




















  • 35





    I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

    – Jörg W Mittag
    2 days ago







  • 23





    @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

    – opa
    2 days ago






  • 7





    You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

    – Tezra
    2 days ago






  • 5





    Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

    – Frax
    2 days ago






  • 5





    In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

    – JLRishe
    yesterday


















6














The Term is Idempotence. Note below that there is a distinct difference between an Idempotent function (Called recursively on itself; Second code block and the Mathematical definition), and functional idempotence (Called repeatedly with same input sequentially; First code block and often the term meant in Programming).




A function f with side effects is said to be idempotent under sequential composition f; f if, when called twice with the same list of arguments, the second call has no side effects and returns the same value as the first call[citation needed] (assuming no other procedures were called between the end of the first call and the start of the second call).



For instance, consider the following Python code:




x = 0

def setx(n):
global x
x = n

setx(5)
setx(5)



Here, setx is idempotent because the second call to setx (with the same argument) does not change the visible program state: x was already set to 5 in the first call, and is again set to 5 in the second call, thus keeping the same value. Note that this is distinct from idempotence under function composition f ∘ f. For example, the absolute value is idempotent under function composition:




def abs(n):
if n < 0:
return -n
else:
return n

abs(-5) == abs(abs(-5)) == abs(5) == 5





share|improve this answer






























    3














    In addition to the other answers, if there is a specific input to the functon that has this property, it is a fixed point, invariant point or fixpoint of the function. For example, 1 to any power is equal to 1, so (1ⁿ)ⁿ = 1ⁿ = 1.



    The special case of a program that produces itself as output is a quine.






    share|improve this answer























    • Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

      – Carl Witthoft
      13 hours ago


















    2














    In physics I've heard this referred to as a projection:




    a projection is a linear transformation P from a vector space to itself such that P2 = P. That is, whenever P is applied twice to any value, it gives the same result as if it were applied once (idempotent).




    Graphically, this makes sense if you look at a cartoon of a vector projection:



    enter image description here



    In the picture, a1 is the projection of a on to b, which is like the first application of your function. Subsequent projections of a1 on to b give the same result a1. In other words, when you call a projection repeatedly, it has the same effect as calling it once.



    Fair warning: I've never heard this used outside of physics, so unless you've got of those types on your team you might confuse everyone.






    share|improve this answer


















    • 2





      This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

      – Pac0
      2 days ago







    • 2





      @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

      – user1717828
      2 days ago



















    2














    It is a Deterministic algorithm because given the same input (in this case no input), it will always produce the same output.




    In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states. Deterministic algorithms are by far the most studied and familiar kind of algorithm, as well as one of the most practical, since they can be run on real machines efficiently.




    SQL databases are interested in Deterministic functions.




    A deterministic function always gives the same answer when it has the same inputs. Most built-in SQL functions in SQLite are deterministic. For example, the abs(X) function always returns the same answer as long as its input X is the same.




    A function must be deterministic if it's used in calculating an index.



    For instance, in SQLite, the following non-deterministic functions cannot be used in an index: random(), changes(), last_insert_rowid() and sqlite3_version().






    share|improve this answer




















    • 6





      The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

      – Draco18s
      2 days ago











    • That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

      – mckenzm
      yesterday









    protected by gnat yesterday



    Thank you for your interest in this question.
    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



    Would you like to answer one of these unanswered questions instead?














    6 Answers
    6






    active

    oldest

    votes








    6 Answers
    6






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    209














    This type of function / operation is called Idempotent




    Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.




    In mathematics, this means that if f is idempotent, f(f(x)) = f(x), which is the same as saying ff = f.



    In computer science, this means that if f(x); is idempotent, f(x); is the same as f(x); f(x);.



    Note: These meanings seem different, but under the denotational semantics of state, the word "idempotent" actually has the same exact meaning in both mathematics and computer science.






    share|improve this answer




















    • 7





      Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

      – Tezra
      2 days ago






    • 7





      @Tezra: Both definitions are acceptable.

      – Dietrich Epp
      2 days ago






    • 5





      Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

      – Jasper
      yesterday






    • 1





      @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

      – Dietrich Epp
      yesterday






    • 1





      @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

      – Tezra
      yesterday
















    209














    This type of function / operation is called Idempotent




    Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.




    In mathematics, this means that if f is idempotent, f(f(x)) = f(x), which is the same as saying ff = f.



    In computer science, this means that if f(x); is idempotent, f(x); is the same as f(x); f(x);.



    Note: These meanings seem different, but under the denotational semantics of state, the word "idempotent" actually has the same exact meaning in both mathematics and computer science.






    share|improve this answer




















    • 7





      Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

      – Tezra
      2 days ago






    • 7





      @Tezra: Both definitions are acceptable.

      – Dietrich Epp
      2 days ago






    • 5





      Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

      – Jasper
      yesterday






    • 1





      @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

      – Dietrich Epp
      yesterday






    • 1





      @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

      – Tezra
      yesterday














    209












    209








    209







    This type of function / operation is called Idempotent




    Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.




    In mathematics, this means that if f is idempotent, f(f(x)) = f(x), which is the same as saying ff = f.



    In computer science, this means that if f(x); is idempotent, f(x); is the same as f(x); f(x);.



    Note: These meanings seem different, but under the denotational semantics of state, the word "idempotent" actually has the same exact meaning in both mathematics and computer science.






    share|improve this answer















    This type of function / operation is called Idempotent




    Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.




    In mathematics, this means that if f is idempotent, f(f(x)) = f(x), which is the same as saying ff = f.



    In computer science, this means that if f(x); is idempotent, f(x); is the same as f(x); f(x);.



    Note: These meanings seem different, but under the denotational semantics of state, the word "idempotent" actually has the same exact meaning in both mathematics and computer science.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 16 hours ago









    Dietrich Epp

    1135




    1135










    answered Mar 4 at 3:43









    WoofasWoofas

    814248




    814248







    • 7





      Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

      – Tezra
      2 days ago






    • 7





      @Tezra: Both definitions are acceptable.

      – Dietrich Epp
      2 days ago






    • 5





      Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

      – Jasper
      yesterday






    • 1





      @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

      – Dietrich Epp
      yesterday






    • 1





      @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

      – Tezra
      yesterday













    • 7





      Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

      – Tezra
      2 days ago






    • 7





      @Tezra: Both definitions are acceptable.

      – Dietrich Epp
      2 days ago






    • 5





      Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

      – Jasper
      yesterday






    • 1





      @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

      – Dietrich Epp
      yesterday






    • 1





      @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

      – Tezra
      yesterday








    7




    7





    Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

    – Tezra
    2 days ago





    Right word, technically wrong/incomplete definition as it applies to programming. Please see the wiki on Side Effects for computer science => en.wikipedia.org/wiki/…

    – Tezra
    2 days ago




    7




    7





    @Tezra: Both definitions are acceptable.

    – Dietrich Epp
    2 days ago





    @Tezra: Both definitions are acceptable.

    – Dietrich Epp
    2 days ago




    5




    5





    Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

    – Jasper
    yesterday





    Note that idempotence is an important concept for HTTP methods, meaning that it has a good formal definition in the RFC as well as tons of more casual explanation (e.g. the one on MDN)

    – Jasper
    yesterday




    1




    1





    @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

    – Dietrich Epp
    yesterday





    @Tezra: This looks like a computer science definition to me, if your idea of “result” includes side effects, that’s really all that needs to be clarified.

    – Dietrich Epp
    yesterday




    1




    1





    @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

    – Tezra
    yesterday






    @jmoreno In the link, there are 2 valid definitions. This answer only includes 1 (and the one usually not meant in the CS context), which is why is said this answer is "wrong/*incomplete*";

    – Tezra
    yesterday














    47














    The precise term for this (as Woofas mentions) is idempotence. I wanted to add that while you could call your func1 method idempotent, you could not call it a pure function. The properties of a pure function are two: it must be idempotent and it must not have side effects, which is to say, no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams.



    The reason I mention this is that a idempotent function with side effects is not good either, since technically idempotent refers to the return output of the function, and not to the side effects. So technically your func2 method is idempotent, as the output doesn't change according to the input.



    You most likely want to specify that you want a pure function. An example of a pure function might be as follows:



    int func1(int var)

    return var + 1;



    More reading can be found in the Wikipedia article "Pure function".






    share|improve this answer




















    • 35





      I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

      – Jörg W Mittag
      2 days ago







    • 23





      @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

      – opa
      2 days ago






    • 7





      You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

      – Tezra
      2 days ago






    • 5





      Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

      – Frax
      2 days ago






    • 5





      In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

      – JLRishe
      yesterday















    47














    The precise term for this (as Woofas mentions) is idempotence. I wanted to add that while you could call your func1 method idempotent, you could not call it a pure function. The properties of a pure function are two: it must be idempotent and it must not have side effects, which is to say, no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams.



    The reason I mention this is that a idempotent function with side effects is not good either, since technically idempotent refers to the return output of the function, and not to the side effects. So technically your func2 method is idempotent, as the output doesn't change according to the input.



    You most likely want to specify that you want a pure function. An example of a pure function might be as follows:



    int func1(int var)

    return var + 1;



    More reading can be found in the Wikipedia article "Pure function".






    share|improve this answer




















    • 35





      I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

      – Jörg W Mittag
      2 days ago







    • 23





      @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

      – opa
      2 days ago






    • 7





      You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

      – Tezra
      2 days ago






    • 5





      Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

      – Frax
      2 days ago






    • 5





      In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

      – JLRishe
      yesterday













    47












    47








    47







    The precise term for this (as Woofas mentions) is idempotence. I wanted to add that while you could call your func1 method idempotent, you could not call it a pure function. The properties of a pure function are two: it must be idempotent and it must not have side effects, which is to say, no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams.



    The reason I mention this is that a idempotent function with side effects is not good either, since technically idempotent refers to the return output of the function, and not to the side effects. So technically your func2 method is idempotent, as the output doesn't change according to the input.



    You most likely want to specify that you want a pure function. An example of a pure function might be as follows:



    int func1(int var)

    return var + 1;



    More reading can be found in the Wikipedia article "Pure function".






    share|improve this answer















    The precise term for this (as Woofas mentions) is idempotence. I wanted to add that while you could call your func1 method idempotent, you could not call it a pure function. The properties of a pure function are two: it must be idempotent and it must not have side effects, which is to say, no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams.



    The reason I mention this is that a idempotent function with side effects is not good either, since technically idempotent refers to the return output of the function, and not to the side effects. So technically your func2 method is idempotent, as the output doesn't change according to the input.



    You most likely want to specify that you want a pure function. An example of a pure function might be as follows:



    int func1(int var)

    return var + 1;



    More reading can be found in the Wikipedia article "Pure function".







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 16 hours ago









    gerrit

    5261419




    5261419










    answered 2 days ago









    NeilNeil

    20.1k3667




    20.1k3667







    • 35





      I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

      – Jörg W Mittag
      2 days ago







    • 23





      @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

      – opa
      2 days ago






    • 7





      You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

      – Tezra
      2 days ago






    • 5





      Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

      – Frax
      2 days ago






    • 5





      In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

      – JLRishe
      yesterday












    • 35





      I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

      – Jörg W Mittag
      2 days ago







    • 23





      @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

      – opa
      2 days ago






    • 7





      You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

      – Tezra
      2 days ago






    • 5





      Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

      – Frax
      2 days ago






    • 5





      In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

      – JLRishe
      yesterday







    35




    35





    I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

    – Jörg W Mittag
    2 days ago






    I think your definition of idempotency is too narrow, or put another way, you are using the mathematical definition of idempotency, not the programming one. For example, the PUT and DELETE HTTP methods are called idempotent precisely because executing their side-effects multiple times has the same effect as executing them only once. You are saying "idempotency means f∘f = f", whereas in programming, we mean "executing f has the same effect has executing f; f". Note that you can easily transform the second meaning into the former by adding a "world" parameter.

    – Jörg W Mittag
    2 days ago





    23




    23





    @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

    – opa
    2 days ago





    @Neil "Idempotency is strictly a mathematical term." No it isn't, its also used in networking and client server communication/distributed systems as well and is described as JörgWMittag describes it. Its a useful concept because it allows multiple requests to a server/client with the same operation/message with out changing what that original message set out to do. This is useful when you have unreliable communication, and you need to retry a command because either the clients message was dropped or the servers reply was.

    – opa
    2 days ago




    7




    7





    You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

    – Tezra
    2 days ago





    You should go into more detail about the difference between pure and idempotent. Your example func1 is not idempotent because func1(1) != func1(func1(1)).

    – Tezra
    2 days ago




    5




    5





    Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

    – Frax
    2 days ago





    Purity and idempotence are different. A pure function doesn't have to be idempotent in mathematical sense (it is abviously idempotent in terms of side-effects, as it has none). Idempotent (in programming sense) function doesn't have to be pure, as in example given by OP. Also, as opa mentioned, idempotence is a useful property with a strictly different use than purity. Your definition of purity as "idempotent and with no side-effects" is wrong or at least misleading, downvoting.

    – Frax
    2 days ago




    5




    5





    In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

    – JLRishe
    yesterday





    In the context of programming, there are no "side effects", but if you were to expand the definition to include this, then a idempotent function and a pure function would mean the same thing. No, they wouldn't mean the same thing at all. Idempotent, not pure: void f(int var) someGlobalVariable = var; . Pure, not idempotent: int func1(int var) return var + 1; .

    – JLRishe
    yesterday











    6














    The Term is Idempotence. Note below that there is a distinct difference between an Idempotent function (Called recursively on itself; Second code block and the Mathematical definition), and functional idempotence (Called repeatedly with same input sequentially; First code block and often the term meant in Programming).




    A function f with side effects is said to be idempotent under sequential composition f; f if, when called twice with the same list of arguments, the second call has no side effects and returns the same value as the first call[citation needed] (assuming no other procedures were called between the end of the first call and the start of the second call).



    For instance, consider the following Python code:




    x = 0

    def setx(n):
    global x
    x = n

    setx(5)
    setx(5)



    Here, setx is idempotent because the second call to setx (with the same argument) does not change the visible program state: x was already set to 5 in the first call, and is again set to 5 in the second call, thus keeping the same value. Note that this is distinct from idempotence under function composition f ∘ f. For example, the absolute value is idempotent under function composition:




    def abs(n):
    if n < 0:
    return -n
    else:
    return n

    abs(-5) == abs(abs(-5)) == abs(5) == 5





    share|improve this answer



























      6














      The Term is Idempotence. Note below that there is a distinct difference between an Idempotent function (Called recursively on itself; Second code block and the Mathematical definition), and functional idempotence (Called repeatedly with same input sequentially; First code block and often the term meant in Programming).




      A function f with side effects is said to be idempotent under sequential composition f; f if, when called twice with the same list of arguments, the second call has no side effects and returns the same value as the first call[citation needed] (assuming no other procedures were called between the end of the first call and the start of the second call).



      For instance, consider the following Python code:




      x = 0

      def setx(n):
      global x
      x = n

      setx(5)
      setx(5)



      Here, setx is idempotent because the second call to setx (with the same argument) does not change the visible program state: x was already set to 5 in the first call, and is again set to 5 in the second call, thus keeping the same value. Note that this is distinct from idempotence under function composition f ∘ f. For example, the absolute value is idempotent under function composition:




      def abs(n):
      if n < 0:
      return -n
      else:
      return n

      abs(-5) == abs(abs(-5)) == abs(5) == 5





      share|improve this answer

























        6












        6








        6







        The Term is Idempotence. Note below that there is a distinct difference between an Idempotent function (Called recursively on itself; Second code block and the Mathematical definition), and functional idempotence (Called repeatedly with same input sequentially; First code block and often the term meant in Programming).




        A function f with side effects is said to be idempotent under sequential composition f; f if, when called twice with the same list of arguments, the second call has no side effects and returns the same value as the first call[citation needed] (assuming no other procedures were called between the end of the first call and the start of the second call).



        For instance, consider the following Python code:




        x = 0

        def setx(n):
        global x
        x = n

        setx(5)
        setx(5)



        Here, setx is idempotent because the second call to setx (with the same argument) does not change the visible program state: x was already set to 5 in the first call, and is again set to 5 in the second call, thus keeping the same value. Note that this is distinct from idempotence under function composition f ∘ f. For example, the absolute value is idempotent under function composition:




        def abs(n):
        if n < 0:
        return -n
        else:
        return n

        abs(-5) == abs(abs(-5)) == abs(5) == 5





        share|improve this answer













        The Term is Idempotence. Note below that there is a distinct difference between an Idempotent function (Called recursively on itself; Second code block and the Mathematical definition), and functional idempotence (Called repeatedly with same input sequentially; First code block and often the term meant in Programming).




        A function f with side effects is said to be idempotent under sequential composition f; f if, when called twice with the same list of arguments, the second call has no side effects and returns the same value as the first call[citation needed] (assuming no other procedures were called between the end of the first call and the start of the second call).



        For instance, consider the following Python code:




        x = 0

        def setx(n):
        global x
        x = n

        setx(5)
        setx(5)



        Here, setx is idempotent because the second call to setx (with the same argument) does not change the visible program state: x was already set to 5 in the first call, and is again set to 5 in the second call, thus keeping the same value. Note that this is distinct from idempotence under function composition f ∘ f. For example, the absolute value is idempotent under function composition:




        def abs(n):
        if n < 0:
        return -n
        else:
        return n

        abs(-5) == abs(abs(-5)) == abs(5) == 5






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        TezraTezra

        19210




        19210





















            3














            In addition to the other answers, if there is a specific input to the functon that has this property, it is a fixed point, invariant point or fixpoint of the function. For example, 1 to any power is equal to 1, so (1ⁿ)ⁿ = 1ⁿ = 1.



            The special case of a program that produces itself as output is a quine.






            share|improve this answer























            • Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

              – Carl Witthoft
              13 hours ago















            3














            In addition to the other answers, if there is a specific input to the functon that has this property, it is a fixed point, invariant point or fixpoint of the function. For example, 1 to any power is equal to 1, so (1ⁿ)ⁿ = 1ⁿ = 1.



            The special case of a program that produces itself as output is a quine.






            share|improve this answer























            • Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

              – Carl Witthoft
              13 hours ago













            3












            3








            3







            In addition to the other answers, if there is a specific input to the functon that has this property, it is a fixed point, invariant point or fixpoint of the function. For example, 1 to any power is equal to 1, so (1ⁿ)ⁿ = 1ⁿ = 1.



            The special case of a program that produces itself as output is a quine.






            share|improve this answer













            In addition to the other answers, if there is a specific input to the functon that has this property, it is a fixed point, invariant point or fixpoint of the function. For example, 1 to any power is equal to 1, so (1ⁿ)ⁿ = 1ⁿ = 1.



            The special case of a program that produces itself as output is a quine.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 days ago









            DavislorDavislor

            1,056610




            1,056610












            • Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

              – Carl Witthoft
              13 hours ago

















            • Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

              – Carl Witthoft
              13 hours ago
















            Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

            – Carl Witthoft
            13 hours ago





            Quines are to software as Cantor sets are to math :-) . And of course quines are not idempotent -- they either fail when the output already exists or they "clobber" the previous result and write a new, albeit identical output.

            – Carl Witthoft
            13 hours ago











            2














            In physics I've heard this referred to as a projection:




            a projection is a linear transformation P from a vector space to itself such that P2 = P. That is, whenever P is applied twice to any value, it gives the same result as if it were applied once (idempotent).




            Graphically, this makes sense if you look at a cartoon of a vector projection:



            enter image description here



            In the picture, a1 is the projection of a on to b, which is like the first application of your function. Subsequent projections of a1 on to b give the same result a1. In other words, when you call a projection repeatedly, it has the same effect as calling it once.



            Fair warning: I've never heard this used outside of physics, so unless you've got of those types on your team you might confuse everyone.






            share|improve this answer


















            • 2





              This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

              – Pac0
              2 days ago







            • 2





              @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

              – user1717828
              2 days ago
















            2














            In physics I've heard this referred to as a projection:




            a projection is a linear transformation P from a vector space to itself such that P2 = P. That is, whenever P is applied twice to any value, it gives the same result as if it were applied once (idempotent).




            Graphically, this makes sense if you look at a cartoon of a vector projection:



            enter image description here



            In the picture, a1 is the projection of a on to b, which is like the first application of your function. Subsequent projections of a1 on to b give the same result a1. In other words, when you call a projection repeatedly, it has the same effect as calling it once.



            Fair warning: I've never heard this used outside of physics, so unless you've got of those types on your team you might confuse everyone.






            share|improve this answer


















            • 2





              This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

              – Pac0
              2 days ago







            • 2





              @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

              – user1717828
              2 days ago














            2












            2








            2







            In physics I've heard this referred to as a projection:




            a projection is a linear transformation P from a vector space to itself such that P2 = P. That is, whenever P is applied twice to any value, it gives the same result as if it were applied once (idempotent).




            Graphically, this makes sense if you look at a cartoon of a vector projection:



            enter image description here



            In the picture, a1 is the projection of a on to b, which is like the first application of your function. Subsequent projections of a1 on to b give the same result a1. In other words, when you call a projection repeatedly, it has the same effect as calling it once.



            Fair warning: I've never heard this used outside of physics, so unless you've got of those types on your team you might confuse everyone.






            share|improve this answer













            In physics I've heard this referred to as a projection:




            a projection is a linear transformation P from a vector space to itself such that P2 = P. That is, whenever P is applied twice to any value, it gives the same result as if it were applied once (idempotent).




            Graphically, this makes sense if you look at a cartoon of a vector projection:



            enter image description here



            In the picture, a1 is the projection of a on to b, which is like the first application of your function. Subsequent projections of a1 on to b give the same result a1. In other words, when you call a projection repeatedly, it has the same effect as calling it once.



            Fair warning: I've never heard this used outside of physics, so unless you've got of those types on your team you might confuse everyone.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 days ago









            user1717828user1717828

            1687




            1687







            • 2





              This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

              – Pac0
              2 days ago







            • 2





              @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

              – user1717828
              2 days ago













            • 2





              This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

              – Pac0
              2 days ago







            • 2





              @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

              – user1717828
              2 days ago








            2




            2





            This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

            – Pac0
            2 days ago






            This is indeed a nice concrete example of how an idempotent function can be visualized (mathematically, and especially in the vector geometry / linear algebra field). While software function's "idempotence" is a really close concept, I don't think developers / computer scientist often use the word "projection" in this context (a "projection function" in software engineering would rather refer to a function that take an object and returns a new object derived from it, or a property of that object, for instance)

            – Pac0
            2 days ago





            2




            2





            @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

            – user1717828
            2 days ago






            @Pac0 Oh, ok. I work on the fringe between science and programming, and didn't realize the word was already overloaded. I can think of a few contrived examples at work where I would use this terminology, but I admittedly work with people that are willing to put up with science jargon on the daily :-)

            – user1717828
            2 days ago












            2














            It is a Deterministic algorithm because given the same input (in this case no input), it will always produce the same output.




            In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states. Deterministic algorithms are by far the most studied and familiar kind of algorithm, as well as one of the most practical, since they can be run on real machines efficiently.




            SQL databases are interested in Deterministic functions.




            A deterministic function always gives the same answer when it has the same inputs. Most built-in SQL functions in SQLite are deterministic. For example, the abs(X) function always returns the same answer as long as its input X is the same.




            A function must be deterministic if it's used in calculating an index.



            For instance, in SQLite, the following non-deterministic functions cannot be used in an index: random(), changes(), last_insert_rowid() and sqlite3_version().






            share|improve this answer




















            • 6





              The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

              – Draco18s
              2 days ago











            • That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

              – mckenzm
              yesterday















            2














            It is a Deterministic algorithm because given the same input (in this case no input), it will always produce the same output.




            In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states. Deterministic algorithms are by far the most studied and familiar kind of algorithm, as well as one of the most practical, since they can be run on real machines efficiently.




            SQL databases are interested in Deterministic functions.




            A deterministic function always gives the same answer when it has the same inputs. Most built-in SQL functions in SQLite are deterministic. For example, the abs(X) function always returns the same answer as long as its input X is the same.




            A function must be deterministic if it's used in calculating an index.



            For instance, in SQLite, the following non-deterministic functions cannot be used in an index: random(), changes(), last_insert_rowid() and sqlite3_version().






            share|improve this answer




















            • 6





              The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

              – Draco18s
              2 days ago











            • That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

              – mckenzm
              yesterday













            2












            2








            2







            It is a Deterministic algorithm because given the same input (in this case no input), it will always produce the same output.




            In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states. Deterministic algorithms are by far the most studied and familiar kind of algorithm, as well as one of the most practical, since they can be run on real machines efficiently.




            SQL databases are interested in Deterministic functions.




            A deterministic function always gives the same answer when it has the same inputs. Most built-in SQL functions in SQLite are deterministic. For example, the abs(X) function always returns the same answer as long as its input X is the same.




            A function must be deterministic if it's used in calculating an index.



            For instance, in SQLite, the following non-deterministic functions cannot be used in an index: random(), changes(), last_insert_rowid() and sqlite3_version().






            share|improve this answer















            It is a Deterministic algorithm because given the same input (in this case no input), it will always produce the same output.




            In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states. Deterministic algorithms are by far the most studied and familiar kind of algorithm, as well as one of the most practical, since they can be run on real machines efficiently.




            SQL databases are interested in Deterministic functions.




            A deterministic function always gives the same answer when it has the same inputs. Most built-in SQL functions in SQLite are deterministic. For example, the abs(X) function always returns the same answer as long as its input X is the same.




            A function must be deterministic if it's used in calculating an index.



            For instance, in SQLite, the following non-deterministic functions cannot be used in an index: random(), changes(), last_insert_rowid() and sqlite3_version().







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 2 days ago

























            answered 2 days ago









            Stephen QuanStephen Quan

            1913




            1913







            • 6





              The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

              – Draco18s
              2 days ago











            • That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

              – mckenzm
              yesterday












            • 6





              The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

              – Draco18s
              2 days ago











            • That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

              – mckenzm
              yesterday







            6




            6





            The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

            – Draco18s
            2 days ago





            The asker's func2 is deterministic (there are no random effects involved), but already declared as violating the property he is looking for.

            – Draco18s
            2 days ago













            That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

            – mckenzm
            yesterday





            That the same result is produced by repetition is not the same as saying the same result is produced by nesting or chaining. Deterministic functions are important for caching results, more so than for indexing/hashing.

            – mckenzm
            yesterday





            protected by gnat yesterday



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?



            Popular posts from this blog

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived