FP (“Functional Programming”) is an algebraic programming language.

FP was invented by John Backus and presented in 1977 in a paper called “Can Programming Be Liberated from the von Neumann style? A Functional Style and its Algebra of Programs”. The language description given in this paper is the de facto standard of the language.

FP was designed as a model of language to support function-level programming style. It was intended to be more of a math model than of an actual language, and so it was. It is a canonical example of a language implementing function-level programming paradigm, but it has only a few implementations which differ quite a lot, and none of them is used in real-life development. However, the concept of FP had strong influence on development of other functional languages.

Most implementations use essentially different language syntax. The following description uses language notation taken from Interactive FP implementation.

As any function-level programming language, FP consists of three groups of entities:

1. atoms. FP uses the following types of atoms:

scalar values. FP is designed to process numerical (both integer and floating-point) and logical (denoted as T and F) data. Some implementations, like Furry Paws, extend the language to allow processing strings as sequences of character codes.

sequences. A sequence is defined as <x 1 , ..., x n > , where x i are another atoms. Note that atoms of different types can be intermixed in one sequence, so <1 <2 5.0> T> is a valid sequence.

, where x are another atoms. Note that atoms of different types can be intermixed in one sequence, so is a valid sequence. undefined value. This is the undefined used in definition of strict and non-strict paradigms: an atom which has no specific value, either because it has not been evaluated yet or because its evaluation has ended in an error. FP is strict language: all its functions and sequences are undefined-preserving, i.e., if function argument or one of elements in sequence is undefined , the return of the function or the sequence itself is undefined as well.

As any function-level language, FP allows the use of atoms only as input and output values of the program. If program logic requires using a constant, a corresponding constant-value function is used.

2. functions can be primitive or user-defined. FP functions always take one atom as argument, which is written as f:x . The list of primitive functions includes:

identity: id:x evaluates to x .

evaluates to . constant-value: %x:y evaluates to x for any value of y (some authors consider % to be a functional form, but it doesn’t have a function-type argument).

evaluates to for any value of (some authors consider % to be a functional form, but it doesn’t have a function-type argument). math +,-,*,/: +:<x y> evaluates to x+y , if x and y are scalar values.

evaluates to , if x and y are scalar values. selector: i:<x 1 ... x n > evaluates to x i , if i is between 1 and n, inclusive.

evaluates to , if i is between 1 and n, inclusive. comparison =,>,<: =:<x y> evaluates to T, if x=y, and to F otherwise.

evaluates to T, if x=y, and to F otherwise. a variety of vector and matrix functions, like concatenate, append, rotate, transpose etc.

user-defined functions have the following syntax: { functionName ( function code ) } . After a function is defined, it can be called in a same way as primitive functions are.

FP is typesafe: the function is evaluated only if its arguments are of correct types.

3. functional forms can not be user-defined. Unlike functions, forms can have multiple arguments. The list of standard forms includes: