wtf wrote: ↑Tue Aug 03, 2021 3:17 am
I wonder if you could name them. I've never heard the term used in math, only in computer science. Never in math, not once. Can you name any of these mathematicians who "keep talking" about something that there is zero evidence they're talking about?
You are missing the point. Surely you understand the difference between syntax and semantics?
I'll paraphrase my meaning: The functions that Mathematicians keep talking ABOUT (ALL functions that Mathematicians concern themselves with) are (supposedly) pure functions!
And I'll paraphrase it once more for an attempt at clarity:
IF a pure function is a function
without side-effects;
AND
ALL Mathematical functions
are without side-effects
THEN Mathematicians ONLY ever talk about pure functions.
In
doing Mathematics they are
doing it (talking ABOUT pure functions) implicitly even if they are not
saying it expliticly.
My claim is semantically true, even if it's not syntactically provable!
And so, of course I can name them! I name any and all Mathematicians! I name you.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
It's your understanding that's incoherent. According to Wiki, a
pure function is " a function that has the following properties:[1][2]
The function return values are identical for identical arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams).
The function application has no side effects (no mutation of local static variables, non-local variables, mutable reference arguments or input/output streams)."
There's no restriction on external input or output. On the contrary, any function must receive some input (even if null) and must return some output value, even if null. You are misunderstanding side effects.
I am not misunderstanding. I am disagreeing with the definition (on grounds that will become clear further below). I am disagreeing with the distinction between inputs/outputs and side-effects on the grounds that they are the exact same thing, so the distinction is a case of special pleading. The distinction is an (unnecessary) double standard.
Your point about null is irelevant too because these all four functions (below) DO the same thing. Nothing!
Code: Select all
def f(x): pass
def g(x=None): pass
def h(a,b,c,d,e,f,g,h,i,.....): pass
def j(): pass
If, for a moment you allow yourself to see through my lens, the lens in which I/O is the exact same thing as side-effects then this happens...
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
A pure function in Python3 would be
Code: Select all
def pure_squarer(x) :
return x * x
It always returns the same output for the same input, and has no external or side effects.
It takes an input! That's a dependency on universe. It's not pure.
It returns! That's an output! That's a side-effect. It's not pure.
Remove the "return" statement. Is this still pure in your view? Can we at least agree that it's not the same function as the one you have given me? It's missing a "return"!
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
For example a non-pure function would be
I have a much much better example of an non-pure function. Equality itself!
Code: Select all
def equal(a,b):
# something happens here. Don't know what.
# If a = b: return True
# else: return False
# Only this is ciruclar. it invokes "=". It invokes itself.
I am yet to see an implementation of equality that does NOT depend on an external input from the Universe.
I am yet to see an implementation that can pass the following unit tests:
Code: Select all
assert equal(1,1)
assert equal(0,0)
assert not equal(0,1)
Until somebody shows me such a function, I am going to go with my intuition on this. Equality is undecidable.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
For gosh sakes, man. That's nonsense.
The only way you could have a pure function by your definition is that if it does nothing. Obviously that's wrong.
Well, YES! That's neither right nor wrong! That is just a direct implication of that particular definition. Is the definition "wrong"? No! It's just a definition. If you insist that the definition is wrong then define "wrong"!
Given that definition it follows that there is only one pure function: NOOP.
Every other function is NOT a pure function.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
That's a pure function. Always returns the same on the same input, no reliance on external state, no side effects.
Yeah, but not through the lens of my definition. It returns. That's an output. Output is a side-effect. Not a pure function.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
That's pathetic. How do you manage to have such wrong ideas? That's a pure function.
Yeah, but not through the lens of my definition. It takes an input. Input is a dependency on the external world. Not a pure function.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
That's a classic example of a pure function.
Yeah, but not throguh the lens of my definition. It takes input (depends on the external world), and returns output (produces a side-effect).
Not a pure function.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
Then it's absolutely useless. Surely you can see that nobody would bother to invent a concept like pure functions if they were no-ops.
That is NOT a no-op function - obviously it DOES something. THIS is a no-op function.
I am not opposing anybody's concepts/inventions. I am just pointing out a muchmore detailed classification schema based on the function's properties!
Surely you can see the
semantic difference between the two functions?
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
So wrong. Read the Wiki page. Read a book.
Define "wrong". Or point me to a book which defines it.
wtf wrote: ↑Tue Aug 03, 2021 3:17 am
I have never seen a mathematician talk about pure functions. Pure functions are part of computer science. Of course if you call computer science a branch of math, as some do, then mathematicians talk about pure functions: namely, those mathematicians who are computer scientists.
I expect the usual incoherent insults in reply. Go.
Look. I am willing to concede the point that Mathematicians never use the term "pure functions" (this is not even relevant to my argument). IF you are willing to concede that mathematicians use the term "function". And since mathematicians use the term "function", and since mathematical functions have inputs and outputs it follows that ALL Mathematical functions are impure (as computer scientists define purity).
Heck! Even assignment IS a side-effect! It mutates memory!