- Functional language: Everything is done calling functions.
- Mathematical 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.
- Background of Lisp: Lambda calculus.
- Church, 1941.
Wikipedia art.
- A Short Introduction
- The lambda operator creates an anonymous function. Maybe:
λx.x×x
But you've already
put in a lot of work if you've already managed to define
multiplication.
- Apply a function to its argument by setting them next to each other.
(λx•x×x)2
- An expression in the language, a term is:
- Variable x is a term.
- If M and N are terms, (MN) is.
- If x is a variable, and M is a terms,
(λx.M) is a term.
- Values, to the extent they exist, are other terms, generally functions.
- Everything is expressed by substitution of a term for the variables
of another.
- Substitution M[x:=N].
- Generally, just substitute N for all
free occurrences of x in M. (A free occurrence is one
that is not already being used as a lambda parameter.)
- (zx)[x:=y]=(zy)
- (zx)[z:=(λz.x+z)]=((λz.x+z)x)
- (λx.x×x)[x:=(λz.x+z)]=(λx.x×x)
- ((λx.M)N)⇒M[x:=N]
- Values are always functions, since there's nothing else. Certain
functions are taken to represent numbers, and arithmetic can be
defined.
- Rather theoretical for my taste, but used to explore the limits
of computation.
- Lisp
- Lisp variations languages approximate an applied lambda 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.
- OCaml
- One of several newer languages descended from ML.
- Functional language with a conventional syntax.
- Hello, World!
- Iteration
- Madlib code
and input.
- OCaml also has strong static typing, while Lisp is dynamically typed.
- Haskell. Notes coming soon.