CSc 404

Overview

Syntax

Names and Scope

Types

Semantics

Functions

Logic Pgmming

Memory Management

Modular and Class Abstraction

Functional Programming

- Functional language: Everything is done calling functions.
- 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.

- Mathmatical variables represent expressions and don't change.
- Background of Lisp: 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|(MN)|(λ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)

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

- Lisp
- 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.

- 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.