Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Equivalency of Code

by bunnyman (Hermit)
on Feb 07, 2005 at 16:09 UTC ( #428716=note: print w/replies, xml ) Need Help??


in reply to Re^2: Equivalency of Code
in thread Equivalency of Code

To spell it out explicitly, there is nothing that f2() can return that would be right.

  • If f2() returns "same", that means f2() and f1() should return the same things. f1() always returns "different" so this is incorrect.
  • If f2() returns "different", that means f2() and f1() should return different things. Now they are both returning the same thing, so this is also incorrect.

The logical conclusion is that function same() does not exist.

Replies are listed 'Best First'.
Re^4: Equivalency of Code
by dynamo (Chaplain) on Feb 07, 2005 at 22:29 UTC
    I disagree with your second idea. f2() and f1() returning the same thing is not the same concept as them having identical functionality.

    To Wit:

    sub f1 { rand; } sub f2 { srand; rand(1); }
    these functions are identical in function, but return different results for the same input.

      Two functions which are identical always return the same result for the same input. That's the definition of a function. Consider that the state of the computer is also an input to the function: if the random seed is the same for both functions, they do return the same results.

      If two functions have the same input (including the exact same environmental states) but do not return the same results (also consider changes to the environment to be "outputs") then they are not the same functions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://428716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2021-10-27 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (95 votes). Check out past polls.

    Notices?