4 ms·
You're mistaking order of evaluating separate functions, from function composition. So if I have two pure functions, f and g, that take and return immutable val
by retrogradeorbit 11y ago
You're mistaking order of evaluating separate functions, from function composition. So if I have two pure functions, f and g, that take and return immutable values (thus having no side effects) I can go:
a = f(x)
b = g(y)
or:
b = g(y)
a = f(x)
And the order does not matter. Because each function cannot effect the other. This is what these quotes are talking about. That independence. There's no outside state mutated in one evaluation affecting the other evaluation.
What you're talking about is function composition. That it f(g(x)) vs g(f(x)). And as many others have said on these threads, the order of the functions when composing two functions together like this is only unimportant if the functions themselves are commutative.