Line by line
Input: values
Output: values
Modify memory registers/RAM
Definitions
Substitutions
e.g y(x) = x + 1
then y(y(x)) = (x + 1) + 1
Immutable values
This was a great improvement on the
machine code that preceded it !
Bugs come from the assumption :
lines above the current one have done things in RAM that are needed
Declare the substitutions that can occur..
let secondElementFunction (a:(b:_)) = b
> [1..]
1,2,3,4,5,6,7,8,9,10,11,12,13......
Infinite Sequences!
> secondElement ( [1..] )
2
Can our function handle infinity?!
Just means to be able to
pass functions as parameters
asyncCall()
.then(function(data1){
// do something...
return anotherAsyncCall();
})
.then(function(data2){
// do something...
return oneMoreAsyncCall();
})
.then(function(data3){
// the third and final async response
})
.fail(function(err) {
// handle any error resulting from any of the above calls
})
.done();
The alternative to line by line control flow
Declare how functions feed into each other rather than using: shared memory, parameters and return values
Pros
Cons
Because we can substitute a list with
its head and then 'the rest' we can reason
about INFINITE data structures!