Functional Programming

[Ch. 1: Overview and History]
[Syntax]
[Names and Scope]
[Types and Type Systems]
[Semantics]
[Functions]
[Memory Management]
[Imperitive Programs and Functional Abstraction]
[Modular and Class Abstraction]
[Functional Programming]
[Logic Programming]

Modular and Class Abstraction | Logic Programming |

- Mathmatical variables represent expressions and don't change.

*No assignment statement in math* - Pure functional languages do not have any form of assignment.

*Most are not pure* - The value of a function or operation depends
*only*on the values of its arguments. - Lambda calculus.
- Church, 1941. Wikipedia art.
- The lambda operator creates an anonymous function.
λ
*x*•*x*×*x* - Apply a function to its argument by setting them next to each other.
(λ
*x*•*x*×*x*) 2 - Rules:
*LambdaExpression*→ *variable*| (*M**N*) | (λ*variable*•*M*)*M*→ *LambdaExpression**N*→ *LambdaExpression* - Bound and free: Bound variables are parameters; free are what's left.
- Substitution
*M*[*x*←*N*].- Generally, just substitute
*N*for all free occurrences of*x*in*M*. - First, though, if
*N*'s un-bound variables are bound in*M*(this is, if they are used as parameters), rename them to remove conflicts, so the substitution leaves the free variables of*N*free. (Obviously, parameter names are indifferent.) - (
*zx*)[*x*←*y*] = (*zy*) - (
*zx*)[*z*← (λ*z*•*x*+*z*)] = ((λ*z*•*x*+*z*)*x*) - (λ
*x*•*x*×*x*)[*x*← (λ*z*•*x*+*z*)] = (λ*x*•*x*×*x*)

- Generally, just substitute
- ((λ
*x*•*M*)*N*) ⇒*M*[*x*←*N*] - Values are always functions, since there's nothing else.
- Applied lamdba calculus adds number and such.

- Lisp variations langauges approximate an applied lamda calculus.
- Notice that
`define`is really a kind of assignment. No one has figured out how to dispense with the impurity. - Lists
- Heap.
- Dot pairs.

- Macros and unevaluated arguments.

Modular and Class Abstraction | Logic Programming |