wtf wrote: ↑Tue Aug 03, 2021 3:17 am
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
Mathematicians keep talking about "pure" functions.
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?
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
A pure function is a function that has no external input and no external output (no side-effects). What incoherent nonsense is this?
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.
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.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
An Input is the universe affecting the function.
An output is the function affecting the universe.
Please read the Wiki page on pure functions. Every function takes an input and returns an output. A pure function does so without creating side effects, and without relying on anything outside the function to determine the output.
For example a non-pure function would be
Code: Select all
import datetime()
def not_pure :
return datetime.datetime.now()
As you can see, the function returns a different value each time it's called, and depends on the time of day.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
Inputs/Outputs ARE side-effects!
For gosh sakes, man. That's nonsense.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
If we use Python as a model of computation this is a pure function, but it does nothing:
Code: Select all
def f(): pass # Mathematical equivalent unknown
The only way you could have a pure function by your definition is that if it does nothing. Obviously that's wrong.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
This is
NOT a pure function. It has outputs.
Code: Select all
def g(): return 1 #Mathematical equivalent f() = 1
That's a pure function. Always returns the same on the same input, no reliance on external state, no side effects.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
This is
NOT a pure function. It mandates input.
Code: Select all
def h(x): pass # Mathematical equivalent unknown
That's pathetic. How do you manage to have such wrong ideas? That's a pure function.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
This is
NOT a pure function - it mandates input and produces output:
Code: Select all
def j(x): return x. # Mathematical equivalent f(x) = x
That's a classic example of a pure function.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
This is a pure function. It calculates the answer to 2+2, but doesn't give you the answer.
Code: Select all
def k(): 2+2 # Mathematical equivalent unknown
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.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
If one takes an extensional view of functions, thereare no such things as pure functions!
So wrong. Read the Wiki page. Read a book.
Skepdick wrote: ↑Tue Jul 20, 2021 1:40 pm
Mathematicians, do you even know what you are talking about when you talk about "pure functions"?
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.