# FP (programming language)

### From Seo Wiki - Search Engine Optimization and Programming Languages

Paradigm | function-level |
---|---|

Appeared in | 1977 |

Designed by | John Backus |

Influenced by | APL |

Influenced | FL, J |

**FP** (short for **F**unction **P**rogramming) is a programming language created by John Backus to support the function-level programming paradigm. This allows for the elimination of named variables.

## Contents |

## Overview

The **values** that FP programs map into one another comprise a set which is closed under **sequence formation**:

ifx_{1},...,x_{n}arevalues, then thesequence〈x_{1},...,x_{n}〉 is also avalue

These values can be built from any set of atoms: booleans, integers, reals, characters, etc.:

boolean: {T,F}integer: {0,1,2,...,∞}character: {'a','b','c',...}symbol: {x,y,...}

**⊥** is the **undefined** value, or **bottom**. Sequences are *bottom-preserving*:

〈x_{1},...,⊥,...,x_{n}〉 =⊥

FP programs are *functions* **f** that each map a single *value* **x** into another:

f:xrepresents thevaluethat results from applying thefunctionfto thevaluex

Functions are either primitive (i.e., provided with the FP environment) or are built from the primitives by **program-forming operations** (also called **functionals**).

An example of primitive function is **constant**, which transforms a value **x** into the constant-valued function **x̄**. Functions are strict:

f:⊥=⊥

Another example of a primitive function is the **selector** function family, denoted by **1**,**2**,... where:

1:〈x_{1},...,x_{n}〉 =x_{1}:〈ix_{1},...,x_{n}〉 =x_{i}if 0 <≤ n = ⊥ otherwisei

## Functionals

In contrast to primitive functions, functionals operate on other functions. For example, some functions have a *unit* value, such as 0 for *addition* and 1 for *multiplication*. The functional **unit** produces such a **value** when applied to a **function f** that has one:

unit += 0unit ×= 1unit foo= ⊥

These are the core functionals of FP:

compositionf°gwheref°g:x=f:(g:x)

construction[f_{1},...f_{n}] where [f_{1},...f_{n}]:x= 〈f_{1}:x,...,f_{n}:x〉

condition(h⇒f;g) where (h⇒f;g):x=f:xifh:x=T=g:xifh:x=F=⊥otherwise

apply-to-allαfwhereαf:〈x_{1},...,x_{n}〉 = 〈f:x_{1},...,f:x_{n}〉

insert-right/fwhere /f:〈x〉 =xand /f:〈x_{1},x_{2},...,x_{n}〉 =f:〈x_{1},/f:〈x_{2},...,x_{n}〉〉 and /f:〈 〉 =unit f

insert-left\fwhere \f:〈x〉 =xand \f:〈x_{1},x_{2},...,x_{n}〉 =f:〈\f:〈x_{1},...,x_{n-1}〉,x_{n}〉 and \f:〈 〉 =unit f

## Equational functions

In addition to being constructed from primitives by functionals, a function may be defined recursively by an equation, the simplest kind being:

f≡Ef

where *E'***f** is an expression built from primitives, other defined functions, and the function symbol **f** itself, using functionals.

## See also

- FL programming language (Backus' successor to FP)
- Function-level programming
- J programming language
- John Backus
- FP84
- FFP - Formal Functional Programming

## References

- Can Programming Be Liberated from the von Neumann Style? Backus' Turing award lecture.de:FP-System

es:Lenguaje de programación FP fr:Functional Programming pt:FP (linguagem de programação)