X + (Y + Z) === (X + Y) + Z
X + Y === Y + X
X + 0 === X
X * (Y + Z) === XY + XZ
This section only covers (1) how in JavaScript function wrapping is often redundant, and (2) that you sometimes need to use =bind= when passing functions around It does not address the fundamental confusion of procedures and functions in JavaScript
you can model a function by a table, and the Javascript notation myFunction[input]
would be equivalent to myFunction(input)
, where in the first myFunction
is an object of key-value pairs and in the second it is actually a function that implements the mathematical relation between input and output.
“A spot of code is referentially transparent when it can be substituted for its evaluated value without changing the behavior of the program.”
“we can run any pure function in parallel since it does not need access to shared memory and it cannot, by definition, have a race condition due to some side effect”
this really just means separating the concept of an action from its execution; the action is a value and can be passed around as a function; the execution or procedure is its side effect