---
title: "Functional Programming"
language: "en"
type: "Guide"
summary: "Functional programming is a highly developed and deeply integrated core feature of the Wolfram Language, made dramatically richer and more convenient through the symbolic nature of the language. Treating expressions like f[x] as both symbolic data and the application of a function f provides a uniquely powerful way to integrate structure and function\\[LongDash]and an efficient, elegant representation of many common computations."
sections: 
  - 
    title: "Applying Functions to Lists"
    link: "paclet:guide/ApplyingFunctionsToLists"
  - 
    title: "Applying Lists of Functions to Arguments"
    link: "null"
  - 
    title: "Iteratively Applying Functions"
    link: "paclet:guide/FunctionalIteration"
  - 
    title: "List-Oriented Functions"
    link: "paclet:guide/RearrangingAndRestructuringLists"
  - 
    title: "Association-Oriented Functions"
    link: "paclet:guide/Associations"
  - 
    title: "Functional Composition"
    link: "paclet:guide/FunctionCompositionAndOperatorForms"
  - 
    title: "\"Curried\" Operator Forms"
    link: "paclet:guide/FunctionCompositionAndOperatorForms"
keywords: 
- ampersand
- anonymous functions
- apply function to all parts
- applying functions
- applying functions to elements of lists
- applying functions to lists of expressions
- applying functions to parts of expression
- applying functions to parts of expressions
- applying functions to parts with indices
- applying functions with multiple arguments
- applying indexed functions
- apply to every part
- Compose (Version 1 function)
- composition of functions
- distribution of operations
- distributive property
- expressions
- fixed point
- fixed point iteration
- fixed point list
- fold list
- functional composition
- function iteration
- iterated functions
- iterated operations
- iteration of unary operators
- lambda expression
- length while
- lists
- lists ordering
- map
- mapcar
- map all
- map at
- map indexed
- map thread
- nesting of functions
- numbered parts of expressions
- performing operations on heads
- prefix operation
- pure function
- simultaneous application
- take while
- tree walking
- unary operators
- unnamed function
- until
- walking through expressions
- while
canonical_url: "https://reference.wolfram.com/language/guide/FunctionalProgramming.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "List Manipulation"
    link: "https://reference.wolfram.com/language/guide/ListManipulation.en.md"
  - 
    title: "Rule-Based Programming"
    link: "https://reference.wolfram.com/language/guide/RulesAndPatterns.en.md"
  - 
    title: "Expressions"
    link: "https://reference.wolfram.com/language/guide/Expressions.en.md"
related_functions: 
  - 
    title: "Append"
    link: "https://reference.wolfram.com/language/ref/Append.en.md"
  - 
    title: "Apply"
    link: "https://reference.wolfram.com/language/ref/Apply.en.md"
  - 
    title: "Array"
    link: "https://reference.wolfram.com/language/ref/Array.en.md"
  - 
    title: "AssociationMap"
    link: "https://reference.wolfram.com/language/ref/AssociationMap.en.md"
  - 
    title: "BlockMap"
    link: "https://reference.wolfram.com/language/ref/BlockMap.en.md"
  - 
    title: "Cases"
    link: "https://reference.wolfram.com/language/ref/Cases.en.md"
  - 
    title: "Comap"
    link: "https://reference.wolfram.com/language/ref/Comap.en.md"
  - 
    title: "ComapApply"
    link: "https://reference.wolfram.com/language/ref/ComapApply.en.md"
  - 
    title: "Composition"
    link: "https://reference.wolfram.com/language/ref/Composition.en.md"
  - 
    title: "CountsBy"
    link: "https://reference.wolfram.com/language/ref/CountsBy.en.md"
  - 
    title: "CurryApplied"
    link: "https://reference.wolfram.com/language/ref/CurryApplied.en.md"
  - 
    title: "FixedPoint"
    link: "https://reference.wolfram.com/language/ref/FixedPoint.en.md"
  - 
    title: "FixedPointList"
    link: "https://reference.wolfram.com/language/ref/FixedPointList.en.md"
  - 
    title: "Fold"
    link: "https://reference.wolfram.com/language/ref/Fold.en.md"
  - 
    title: "FoldList"
    link: "https://reference.wolfram.com/language/ref/FoldList.en.md"
  - 
    title: "FoldPair"
    link: "https://reference.wolfram.com/language/ref/FoldPair.en.md"
  - 
    title: "FoldWhile"
    link: "https://reference.wolfram.com/language/ref/FoldWhile.en.md"
  - 
    title: "Function"
    link: "https://reference.wolfram.com/language/ref/Function.en.md"
  - 
    title: "GatherBy"
    link: "https://reference.wolfram.com/language/ref/GatherBy.en.md"
  - 
    title: "GroupBy"
    link: "https://reference.wolfram.com/language/ref/GroupBy.en.md"
  - 
    title: "Identity"
    link: "https://reference.wolfram.com/language/ref/Identity.en.md"
  - 
    title: "KeySortBy"
    link: "https://reference.wolfram.com/language/ref/KeySortBy.en.md"
  - 
    title: "LengthWhile"
    link: "https://reference.wolfram.com/language/ref/LengthWhile.en.md"
  - 
    title: "Map"
    link: "https://reference.wolfram.com/language/ref/Map.en.md"
  - 
    title: "MapAll"
    link: "https://reference.wolfram.com/language/ref/MapAll.en.md"
  - 
    title: "MapApply"
    link: "https://reference.wolfram.com/language/ref/MapApply.en.md"
  - 
    title: "MapAt"
    link: "https://reference.wolfram.com/language/ref/MapAt.en.md"
  - 
    title: "MapIndexed"
    link: "https://reference.wolfram.com/language/ref/MapIndexed.en.md"
  - 
    title: "MapThread"
    link: "https://reference.wolfram.com/language/ref/MapThread.en.md"
  - 
    title: "MaximalBy"
    link: "https://reference.wolfram.com/language/ref/MaximalBy.en.md"
  - 
    title: "Nest"
    link: "https://reference.wolfram.com/language/ref/Nest.en.md"
  - 
    title: "NestGraph"
    link: "https://reference.wolfram.com/language/ref/NestGraph.en.md"
  - 
    title: "NestList"
    link: "https://reference.wolfram.com/language/ref/NestList.en.md"
  - 
    title: "NestWhile"
    link: "https://reference.wolfram.com/language/ref/NestWhile.en.md"
  - 
    title: "NestWhileList"
    link: "https://reference.wolfram.com/language/ref/NestWhileList.en.md"
  - 
    title: "Operate"
    link: "https://reference.wolfram.com/language/ref/Operate.en.md"
  - 
    title: "OperatorApplied"
    link: "https://reference.wolfram.com/language/ref/OperatorApplied.en.md"
  - 
    title: "Position"
    link: "https://reference.wolfram.com/language/ref/Position.en.md"
  - 
    title: "ReverseApplied"
    link: "https://reference.wolfram.com/language/ref/ReverseApplied.en.md"
  - 
    title: "Scan"
    link: "https://reference.wolfram.com/language/ref/Scan.en.md"
  - 
    title: "Select"
    link: "https://reference.wolfram.com/language/ref/Select.en.md"
  - 
    title: "SequenceFold"
    link: "https://reference.wolfram.com/language/ref/SequenceFold.en.md"
  - 
    title: "SequenceFoldList"
    link: "https://reference.wolfram.com/language/ref/SequenceFoldList.en.md"
  - 
    title: "SortBy"
    link: "https://reference.wolfram.com/language/ref/SortBy.en.md"
  - 
    title: "SplitBy"
    link: "https://reference.wolfram.com/language/ref/SplitBy.en.md"
  - 
    title: "SubsetMap"
    link: "https://reference.wolfram.com/language/ref/SubsetMap.en.md"
  - 
    title: "TakeWhile"
    link: "https://reference.wolfram.com/language/ref/TakeWhile.en.md"
  - 
    title: "Through"
    link: "https://reference.wolfram.com/language/ref/Through.en.md"
related_tutorials: 
  - 
    title: "Pure Functions"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#17469"
  - 
    title: "Variables in Pure Functions and Rules"
    link: "https://reference.wolfram.com/language/tutorial/ModularityAndTheNamingOfThings.en.md#1131"
  - 
    title: "Applying Functions to Lists and Other Expressions"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#3829"
  - 
    title: "Applying Functions to Parts of Expressions"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#28027"
  - 
    title: "Applying Functions Repeatedly"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#23850"
  - 
    title: "Selecting Parts of Expressions with Functions"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#5821"
  - 
    title: "Working with Operators"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#27825"
---
# Functional Programming

Functional programming is a highly developed and deeply integrated core feature of the Wolfram Language, made dramatically richer and more convenient through the symbolic nature of the language. Treating expressions like ``f[x]`` as both symbolic data and the application of a function f provides a uniquely powerful way to integrate structure and function—and an efficient, elegant representation of many common computations.

---

[`Function`](https://reference.wolfram.com/language/ref/Function.en.md) ([`&`](https://reference.wolfram.com/language/ref/Function.en.md)) — specify a pure function (e.g. ``(# + 1)&``)

[`\#`](https://reference.wolfram.com/language/ref/Slot.en.md), [`\#\#`](https://reference.wolfram.com/language/ref/SlotSequence.en.md), [`\#name`](https://reference.wolfram.com/language/ref/Slot.en.md) — slots for variables in a pure function

### [Applying Functions to Lists](https://reference.wolfram.com/language/guide/ApplyingFunctionsToLists.en.md)

[`Map`](https://reference.wolfram.com/language/ref/Map.en.md) ([`/@`](https://reference.wolfram.com/language/ref/Map.en.md)) — map across a list: ``f /@ {x, y, z}``⟶``{f[x], f[y], f[z]}``

[`Apply`](https://reference.wolfram.com/language/ref/Apply.en.md) ([`@@`](https://reference.wolfram.com/language/ref/Apply.en.md)) — apply to a list: ``f@@{x, y, z}``⟶``f[x, y, z]``

[`MapApply`](https://reference.wolfram.com/language/ref/MapApply.en.md) ([`@@@`](https://reference.wolfram.com/language/ref/MapApply.en.md)) — apply to a list: ``f@@@{x, y, z}``⟶``{f@@x, f@@y, f@@z}``

[`MapIndexed`](https://reference.wolfram.com/language/ref/MapIndexed.en.md) — map with index information: ``{f[x, {1}], f[y, {2}], f[z, {3}]}``

* [`MapThread`](https://reference.wolfram.com/language/ref/MapThread.en.md)
* [`MapAt`](https://reference.wolfram.com/language/ref/MapAt.en.md)
* [`MapAll`](https://reference.wolfram.com/language/ref/MapAll.en.md)
* [`Scan`](https://reference.wolfram.com/language/ref/Scan.en.md)
* [`BlockMap`](https://reference.wolfram.com/language/ref/BlockMap.en.md)
* [`SubsetMap`](https://reference.wolfram.com/language/ref/SubsetMap.en.md)
* [`...`](https://reference.wolfram.com/language/guide/ApplyingFunctionsToLists.en.md)

### Applying Lists of Functions to Arguments

[`Comap`](https://reference.wolfram.com/language/ref/Comap.en.md) — comap into a list: ``Comap[{f, g, h}, x]``⟶``{f[x], g[x], h[x]}``

[`ComapApply`](https://reference.wolfram.com/language/ref/ComapApply.en.md) — use multivariate heads: ``ComapApply[{f, g, …}, x]``⟶``{f@@x, g@@x, …}``

### [Iteratively Applying Functions](https://reference.wolfram.com/language/guide/FunctionalIteration.en.md)

[`Nest`](https://reference.wolfram.com/language/ref/Nest.en.md), [`NestList`](https://reference.wolfram.com/language/ref/NestList.en.md), [`NestGraph`](https://reference.wolfram.com/language/ref/NestGraph.en.md) — nest a function: ``f[f[f[x]]]`` etc.

[`Fold`](https://reference.wolfram.com/language/ref/Fold.en.md), [`FoldList`](https://reference.wolfram.com/language/ref/FoldList.en.md) — fold in a list of values: ``f[f[f[x, 1], 2], 3]`` etc.

* [`SequenceFold`](https://reference.wolfram.com/language/ref/SequenceFold.en.md)
* [`SequenceFoldList`](https://reference.wolfram.com/language/ref/SequenceFoldList.en.md)
* [`FoldPair`](https://reference.wolfram.com/language/ref/FoldPair.en.md)
* [`FoldWhile`](https://reference.wolfram.com/language/ref/FoldWhile.en.md)
* [`...`](https://reference.wolfram.com/language/guide/FunctionalIteration.en.md)

[`FixedPoint`](https://reference.wolfram.com/language/ref/FixedPoint.en.md), [`FixedPointList`](https://reference.wolfram.com/language/ref/FixedPointList.en.md) — repeatedly nest until a fixed point

* [`NestWhile`](https://reference.wolfram.com/language/ref/NestWhile.en.md)
* [`NestWhileList`](https://reference.wolfram.com/language/ref/NestWhileList.en.md)
* [`TakeWhile`](https://reference.wolfram.com/language/ref/TakeWhile.en.md)
* [`LengthWhile`](https://reference.wolfram.com/language/ref/LengthWhile.en.md)
* [`...`](https://reference.wolfram.com/language/guide/FunctionalIteration.en.md)

---

### [List-Oriented Functions](https://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.en.md)

[`Select`](https://reference.wolfram.com/language/ref/Select.en.md) — select from a list according to a function

[`Array`](https://reference.wolfram.com/language/ref/Array.en.md) — create an array from a function

* [`SortBy`](https://reference.wolfram.com/language/ref/SortBy.en.md)
* [`MaximalBy`](https://reference.wolfram.com/language/ref/MaximalBy.en.md)
* [`SplitBy`](https://reference.wolfram.com/language/ref/SplitBy.en.md)
* [`GatherBy`](https://reference.wolfram.com/language/ref/GatherBy.en.md)
* [`...`](https://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.en.md)

### [Association-Oriented Functions](https://reference.wolfram.com/language/guide/Associations.en.md)

[`AssociationMap`](https://reference.wolfram.com/language/ref/AssociationMap.en.md) — create an association from a function

* [`KeySortBy`](https://reference.wolfram.com/language/ref/KeySortBy.en.md)
* [`CountsBy`](https://reference.wolfram.com/language/ref/CountsBy.en.md)
* [`GroupBy`](https://reference.wolfram.com/language/ref/GroupBy.en.md)
* [`...`](https://reference.wolfram.com/language/guide/Associations.en.md)

---

### [Functional Composition](https://reference.wolfram.com/language/guide/FunctionCompositionAndOperatorForms.en.md)

* [`Identity`](https://reference.wolfram.com/language/ref/Identity.en.md)
* [`Composition`](https://reference.wolfram.com/language/ref/Composition.en.md)
* [`ReverseApplied`](https://reference.wolfram.com/language/ref/ReverseApplied.en.md)
* [`Operate`](https://reference.wolfram.com/language/ref/Operate.en.md)
* [`Through`](https://reference.wolfram.com/language/ref/Through.en.md)
* [`...`](https://reference.wolfram.com/language/guide/FunctionCompositionAndOperatorForms.en.md)

### [Curried" Operator Forms](https://reference.wolfram.com/language/guide/FunctionCompositionAndOperatorForms.en.md)

[`OperatorApplied`](https://reference.wolfram.com/language/ref/OperatorApplied.en.md) — make a function be applied in operator form

* [`CurryApplied`](https://reference.wolfram.com/language/ref/CurryApplied.en.md)
* [`Select`](https://reference.wolfram.com/language/ref/Select.en.md)
* [`Cases`](https://reference.wolfram.com/language/ref/Cases.en.md)
* [`Append`](https://reference.wolfram.com/language/ref/Append.en.md)
* [`Map`](https://reference.wolfram.com/language/ref/Map.en.md)
* [`Position`](https://reference.wolfram.com/language/ref/Position.en.md)
* [`...`](https://reference.wolfram.com/language/guide/FunctionCompositionAndOperatorForms.en.md)

## Tech Notes

* [Pure Functions](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#17469)
* [Variables in Pure Functions and Rules](https://reference.wolfram.com/language/tutorial/ModularityAndTheNamingOfThings.en.md#1131)
* [Applying Functions to Lists and Other Expressions](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#3829)
* [Applying Functions to Parts of Expressions](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#28027)
* [Applying Functions Repeatedly](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#23850)
* [Selecting Parts of Expressions with Functions](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#5821)
* [Working with Operators](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#27825)

## Related Guides

* [List Manipulation](https://reference.wolfram.com/language/guide/ListManipulation.en.md)
* [Rule-Based Programming](https://reference.wolfram.com/language/guide/RulesAndPatterns.en.md)
* [`Expressions`](https://reference.wolfram.com/language/guide/Expressions.en.md)