Relative Content

Tag Archive for functions

Returning status code where one of many errors could have occured

I’m developing a PHP login component which includes functions to manipulate the User object, such as $User->changePassword(string $old, string $new)
What I need some advice with is how to return a status, as the function can either succeed (no further information needs to be given) or fail (and the calling code needs to know why, for example incorrect password, database problem etc.)

Why store a function inside a python dictionary?

I’m a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me this is a deep and very pythonic concept and I’m not quite grasping its importance. Can someone put a name to this technique and explain how/why it’s useful?

Why is Today() an example of an impure function?

It seems like, when reading something like this Wikipedia article about “pure functions”, they list Today() as an example of an impure function but it seems pretty pure to me. Is it because there is no formal input argument? Why is the actual time of day not treated as the “input to the function” in which case if you gave it the same input, i.e. executed today() twice at the same time, or traveled back in time to execute it again (maybe a hypothetical 🙂 ), the output would be the same time. Today() never gives you a random number. it always gives you the time of day.

Renaming long named method in C# [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for […]

LOOP-computable functions

I was just reading a chapter about LOOP-computable functions and I have the following question: Is it possible to numerate every LOOP program with an algorithm?