Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Function
  • See Also
    • Apply
    • Construct
    • CurryApplied
    • ApplyTo
    • CompiledFunction
    • InterpolatingFunction
    • Slot
    • SlotSequence
    • FunctionCompile
    • IncrementalFunction

    • Characters
    • \[Function]
  • Related Guides
    • Functional Programming
    • Scoping Constructs
    • Attributes
    • Function Composition & Operator Forms
    • Wolfram Language Syntax
    • Computation with Structured Datasets
    • Language Overview
    • Combinatory Logic
  • Workflows
    • Apply a Function to Cells in a Notebook
  • Tech Notes
    • Pure Functions
    • Variables in Pure Functions and Rules
    • Some General Notations and Conventions
    • See Also
      • Apply
      • Construct
      • CurryApplied
      • ApplyTo
      • CompiledFunction
      • InterpolatingFunction
      • Slot
      • SlotSequence
      • FunctionCompile
      • IncrementalFunction

      • Characters
      • \[Function]
    • Related Guides
      • Functional Programming
      • Scoping Constructs
      • Attributes
      • Function Composition & Operator Forms
      • Wolfram Language Syntax
      • Computation with Structured Datasets
      • Language Overview
      • Combinatory Logic
    • Workflows
      • Apply a Function to Cells in a Notebook
    • Tech Notes
      • Pure Functions
      • Variables in Pure Functions and Rules
      • Some General Notations and Conventions

body& or Function[body]

is a pure (or "anonymous") function. The formal parameters are # (or #1), #2, etc.

x|->body or xbody or Function[x,body]

is a pure function with a single formal parameter x.

{x1,x2,…}|->body or {x1,x2,…}body or Function[{x1,x2,…},body]

is a pure function with a list of formal parameters.

Function[params,body,attrs]

is a pure function that is treated as having attributes attrs for purposes of evaluation.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Use a Pure Function as an Argument  
Use a Pure Function as an Option Value  
Return a Pure Function as a Result  
Function and Associations  
Generalizations & Extensions  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Tech Notes
Related Guides
Related Workflows
Related Links
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • Apply
    • Construct
    • CurryApplied
    • ApplyTo
    • CompiledFunction
    • InterpolatingFunction
    • Slot
    • SlotSequence
    • FunctionCompile
    • IncrementalFunction

    • Characters
    • \[Function]
  • Related Guides
    • Functional Programming
    • Scoping Constructs
    • Attributes
    • Function Composition & Operator Forms
    • Wolfram Language Syntax
    • Computation with Structured Datasets
    • Language Overview
    • Combinatory Logic
  • Workflows
    • Apply a Function to Cells in a Notebook
  • Tech Notes
    • Pure Functions
    • Variables in Pure Functions and Rules
    • Some General Notations and Conventions
    • See Also
      • Apply
      • Construct
      • CurryApplied
      • ApplyTo
      • CompiledFunction
      • InterpolatingFunction
      • Slot
      • SlotSequence
      • FunctionCompile
      • IncrementalFunction

      • Characters
      • \[Function]
    • Related Guides
      • Functional Programming
      • Scoping Constructs
      • Attributes
      • Function Composition & Operator Forms
      • Wolfram Language Syntax
      • Computation with Structured Datasets
      • Language Overview
      • Combinatory Logic
    • Workflows
      • Apply a Function to Cells in a Notebook
    • Tech Notes
      • Pure Functions
      • Variables in Pure Functions and Rules
      • Some General Notations and Conventions

Function

body& or Function[body]

is a pure (or "anonymous") function. The formal parameters are # (or #1), #2, etc.

x|->body or xbody or Function[x,body]

is a pure function with a single formal parameter x.

{x1,x2,…}|->body or {x1,x2,…}body or Function[{x1,x2,…},body]

is a pure function with a list of formal parameters.

Function[params,body,attrs]

is a pure function that is treated as having attributes attrs for purposes of evaluation.

Details

  • When Function[body] or body& is applied to a set of arguments, # (or #1) is replaced by the first argument, #2 by the second, and so on. #0 is replaced by the function itself.
  • If there are more arguments supplied than # i in the function, the remaining arguments are ignored. »
  • ## stands for the sequence of all arguments supplied. »
  • ## n stands for arguments from number n onward. »
  • When applied to an association, #name is equivalent to #["name"], and picks out elements in the association.
  • In the form #name, the characters in name can be any combination of alphanumeric characters not beginning with digits.
  • The character  is entered as |->, fn or \[Function].
  • Function is analogous to λ in LISP or formal logic.
  • Function has attribute HoldAll. The function body is evaluated only after the formal parameters have been replaced by arguments.
  • The named formal parameters xi in Function[{x1,…},body] are treated as local, and are renamed xi$ when necessary to avoid confusion with actual arguments supplied to the function. »
  • Function constructs can be nested in any way. Each is treated as a scoping construct, with named inner variables being renamed if necessary. »
  • In Function[params,body,attrs], attrs can be a single attribute or a list of attributes. »
  • Function[Null,body,attrs] represents a function in which the parameters in body are given using # etc.

Examples

open all close all

Basic Examples  (4)

Pure function with one parameter:

Wolfram Language code: Function[u, 3 + u][x]
Wolfram Language code: Function[3 + #][x]
Wolfram Language code: (3 + #)&[x]

Pure function with two parameters:

Wolfram Language code: Function[{u, v}, u ^ 2 + v ^ 4][x, y]
Wolfram Language code: (#1 ^ 2 + #2 ^ 4)&[x, y]

Set to be a pure function:

Wolfram Language code: f = (3 + #)&

Use the pure function:

Wolfram Language code: {f[a], f[b]}

Pick out named arguments from an association:

Wolfram Language code: f[#u, #v, #u]&[<|"u" -> x, "v" -> y|>]

Scope  (15)

Use a Pure Function as an Argument  (5)

Map a pure function over a list:

Wolfram Language code: g[#, # ^ 2]& /@ {x, y, z}

Select with a pure function:

Wolfram Language code: Select[{1, -1, 2, -2, 3}, # > 0&]

Use a pure function as a predicate:

Wolfram Language code: Cases[{1, -1, 2, -2, 3}, _Integer ? (# > 0&)]

Create an array from a pure function:

Wolfram Language code: Array[1 + # ^ 2&, 10]

Sort by comparing the second part of each element:

Wolfram Language code: Sort[{{a, 2}, {c, 1}, {d, 3}}, #1[[2]] < #2[[2]]&]

Use a Pure Function as an Option Value  (3)

Specify a custom comparison function in FixedPoint:

Wolfram Language code: FixedPoint[(# + 2 / # ) / 2&, 1`20, SameTest -> (Abs[#1 - #2] < 1*^-10&)]

Specify a custom color function:

Wolfram Language code: DensityPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, ColorFunction -> (RGBColor[1 - #, #, 1 - #]&)]

Provide a custom distance function:

Wolfram Language code: Nearest[{1, 2, 4, 8, 16}, 5, DistanceFunction -> ((#1 - #2) ^ 2&)]

Return a Pure Function as a Result  (4)

Derivative of a pure function:

Wolfram Language code: Function[x, x ^ 2]'

Derivative of Tan:

Wolfram Language code: Tan'

Solutions of differential equations may be expressed as pure functions:

Wolfram Language code: DSolve[{y'[x] == ay[x], y[0] == 1}, y, x]

Difference equations may return pure functions:

Wolfram Language code: RSolve[{a[n + 1] - 2a[n] == 1, a[0] == 1}, a, n]

Function and Associations  (3)

#name is effectively a short form of #["name"]:

Wolfram Language code: #x&[<|"x" -> a, "y" -> b|>]
Wolfram Language code: #["x"]&[<|"x" -> a, "y" -> b|>]

#name always refers to the association in the first argument:

Wolfram Language code: #y&[<|"x" -> 1, "y" -> 2|>, <|"x" -> 3, "y" -> 4|>]

Extract from an association slot other than the first:

Wolfram Language code: #2["y"]&[<|"x" -> 1, "y" -> 2|>, <|"x" -> 3, "y" -> 4|>]

Generalizations & Extensions  (4)

## stands for all arguments:

Wolfram Language code: f[##]&[a, b, c, d]
Wolfram Language code: f[X, ##, Y, ##]&[a, b, c, d]

## n stands for arguments n and onward:

Wolfram Language code: f[##2]&[a, b, c, d]
Wolfram Language code: f[##1, X, ##2, Y, ##3, Z, ##4]&[a, b, c, d]

Create a pure function with attribute Listable:

Wolfram Language code: Function[{u}, g[u], Listable][{a, b, c}]
Wolfram Language code: Function[{u}, g[u]][{a, b, c}]

#0 stands for the whole pure function:

Wolfram Language code: f[#0]&[x]

A recursive definition for factorial using #0:

Wolfram Language code: f = If[#1 == 1, 1, #1 #0[#1 - 1]]&
Wolfram Language code: f[10]

Applications  (3)

Turn a function that takes several arguments into one that takes a list of arguments:

Wolfram Language code: cplus = Plus@@#&
Wolfram Language code: cplus[{a, b, c}]

A function that returns a function that multiplies its argument by n:

Wolfram Language code: makef[n_] := Function[x, n x]
Wolfram Language code: f2 = makef[2]
Wolfram Language code: f2[5]

Preserve arguments in unevaluated form:

Wolfram Language code: Select[Hold[x, $MaxMachineNumber], Function[symbol, Context[symbol] === "System`", HoldAll]]

Properties & Relations  (11)

#1 uses only the first argument supplied; the rest are ignored:

Wolfram Language code: f[#1]&[x, y, z]

Not using any arguments results in a constant pure function:

Wolfram Language code: 17& /@ {1, 2, 3}

Replacements can be done inside pure functions:

Wolfram Language code: (p + #)& /. p -> q
Wolfram Language code: %[x]

Formal parameters are renamed whenever there is a possibility of confusion:

Wolfram Language code: Function[{x}, Function[{y}, f[x, y]]][y]
Wolfram Language code: Function[{x}, Function[{y}, f[x, y]]][a]
Wolfram Language code: Function[{x}, Function[{y}, Function[{z}, f[x, y, z]]]][a]

The names of the parameters do not matter:

Wolfram Language code: Function[x, Function[y, x ^ y]][x][y]
Wolfram Language code: Function[y, Function[x, y ^ x]][x][y]

However, reusing a name introduces a new scope:

Wolfram Language code: Function[x, Function[x, x ^ x]][x][y]

Nested functions take their arguments one at a time:

Wolfram Language code: Function[x, Function[y, x ^ y]][a][b]
Wolfram Language code: Function[{x, y}, x ^ y][a, b]

f[#]& is the same as simply f in the univariate case:

Wolfram Language code: f[#]&[a]

In general, f[##]& is the same as f:

Wolfram Language code: f[##]&[a, b, c]

Turn a formula involving a variable into a pure function:

Wolfram Language code: formula = (1 + x) ^ 2;
Wolfram Language code: Function[x, Evaluate[formula]]

Use a formula in Table:

Wolfram Language code: Table[i ^ 2, {i, 10}]

Use the corresponding pure function in an equivalent Array expression:

Wolfram Language code: Array[# ^ 2&, 10]

Special-purpose function constructs include InterpolatingFunction:

Wolfram Language code: f = Interpolation[{1, 2, 4, 5, 6}]
Wolfram Language code: f[4]

CompiledFunction:

Wolfram Language code: f = Compile[{x}, x ^ 2]
Wolfram Language code: f[5.0]

NearestFunction:

Wolfram Language code: f = Nearest[{1, 2, 3, 4, 5}]
Wolfram Language code: f[3.1]

LinearSolveFunction:

Wolfram Language code: f = LinearSolve[{{1, 2}, {3, 4}}]
Wolfram Language code: f[{5, 6}]

Possible Issues  (4)

& binds more loosely than ->, so it usually needs parentheses in rules:

Wolfram Language code: FullForm[x -> y&]
Wolfram Language code: FullForm[x -> (y&)]

& binds more loosely than ?, so it usually needs parentheses in pattern tests:

Wolfram Language code: Cases[{1, 2, 3, 4}, _ ? (OddQ[# / 2]&)]

Function does not evaluate its body until the function is applied:

Wolfram Language code: (# + # + #)&
Wolfram Language code: %[a]

Supplying fewer than the required number of arguments generates an error:

Wolfram Language code: #2&[x]

Neat Examples  (2)

Define the recursion operator of recursion theory [more info]:

Wolfram Language code: r[g_, h_] = If[#1 == 0, g[##2], h[#0[#1 - 1, ##2], #1 - 1, ##2]]&

Use it to define the factorial function:

Wolfram Language code: r[1&, #1(#2 + 1)&][10]

Newton's formula for finding a zero of a function:

Wolfram Language code: NewtonZero[f_, x0_] := FixedPoint[# - f[#] / f'[#]&, x0]
Wolfram Language code: NewtonZero[BesselJ[2, #]&, 5.0]

See Also

Apply  Construct  CurryApplied  ApplyTo  CompiledFunction  InterpolatingFunction  Slot  SlotSequence  FunctionCompile  IncrementalFunction

Characters: \[Function]

Function Repository: ExpressionToFunction

Tech Notes

    ▪
  • Pure Functions
  • ▪
  • Variables in Pure Functions and Rules
  • ▪
  • Some General Notations and Conventions

Related Guides

    ▪
  • Functional Programming
  • ▪
  • Scoping Constructs
  • ▪
  • Attributes
  • ▪
  • Function Composition & Operator Forms
  • ▪
  • Wolfram Language Syntax
  • ▪
  • Computation with Structured Datasets
  • ▪
  • Language Overview
  • ▪
  • Combinatory Logic

Related Workflows

    Related Workflows
    ▪
  • Apply a Function to Cells in a Notebook

Related Links

  • Fast Introduction for Programmers: Pure Functions
  • An Elementary Introduction to the Wolfram Language : Pure Anonymous Functions
  • NKS|Online  (A New Kind of Science)

History

Introduced in 1988 (1.0) | Updated in 2008 (7.0) ▪ 2014 (10.0) ▪ 2020 (12.2)

Wolfram Research (1988), Function, Wolfram Language function, https://reference.wolfram.com/language/ref/Function.html (updated 2020).

Text

Wolfram Research (1988), Function, Wolfram Language function, https://reference.wolfram.com/language/ref/Function.html (updated 2020).

CMS

Wolfram Language. 1988. "Function." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/Function.html.

APA

Wolfram Language. (1988). Function. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Function.html

BibTeX

@misc{reference.wolfram_2026_function, author="Wolfram Research", title="{Function}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Function.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_function, organization={Wolfram Research}, title={Function}, year={2020}, url={https://reference.wolfram.com/language/ref/Function.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English