Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • Compute Services
  • System Modeler
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

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

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

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

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

Wolfram Consulting

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • 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/STEAM
  • 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
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Notebook Assistant + LLM Kit
    • Compute Services
    • System Modeler
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

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

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • 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/STEAM
      • 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
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
DownValuesFunction
  • See Also
    • FunctionCompile
    • Typed
    • FunctionDeclaration
    • DownValues
    • SetDelayed
    • KernelEvaluate
    • KernelFunction
  • Related Guides
    • Code Compilation
  • Tech Notes
    • Wolfram Compiler Manual
    • See Also
      • FunctionCompile
      • Typed
      • FunctionDeclaration
      • DownValues
      • SetDelayed
      • KernelEvaluate
      • KernelFunction
    • Related Guides
      • Code Compilation
    • Tech Notes
      • Wolfram Compiler Manual

DownValuesFunction[sym]

represents a function that uses definitions attached to sym when compiling.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Multiple Definitions  
Multiple Declarations  
Polymorphic Declarations  
Show More Show More
Recursive Calls  
Unnamed Patterns  
Repeated Patterns  
Matching the Head  
Pattern Test  
Condition  
Except  
Alternatives  
Compound Patterns  
Sequences  
Applications  
Symbol Definitions  
Possible Issues  
Updating  
Definition Restrictions  
Type Consistency  
Unsupported Patterns  
Sequence Patterns  
See Also
Tech Notes
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • FunctionCompile
    • Typed
    • FunctionDeclaration
    • DownValues
    • SetDelayed
    • KernelEvaluate
    • KernelFunction
  • Related Guides
    • Code Compilation
  • Tech Notes
    • Wolfram Compiler Manual
    • See Also
      • FunctionCompile
      • Typed
      • FunctionDeclaration
      • DownValues
      • SetDelayed
      • KernelEvaluate
      • KernelFunction
    • Related Guides
      • Code Compilation
    • Tech Notes
      • Wolfram Compiler Manual

DownValuesFunction

DownValuesFunction[sym]

represents a function that uses definitions attached to sym when compiling.

Details

  • DownValuesFunction can be used directly in compiled code.
  • DownValuesFunction can be used in compiled declarations specified by FunctionDeclaration.
  • DownValuesFunction specifications typically use Typed to give type annotations.
  • When DownValuesFunction is compiled, it creates a function from symbol declarations and compiles it.
  • Declarations that use DownValuesFunction can use polymorphic types.
  • The following pattern constructs are supported:
  • _match an argument
    x_match an argument assigning to the name x
    _hmatch if the head is h
    x_?testmatch if test[x] evaluates to True
    p/;condmatch if cond evaluates to True
    Except[p]match if p does not match
    p1|p2match if one of pi matches
    f[g[p]]match a compound expression (for inert expressions and packed arrays)
    __,___match a sequence (for inert expressions)

Examples

open all close all

Basic Examples  (1)

Define a squaring function and use its definition to create a compiled function for the integer-typed case:

Use the compiled function with an integer argument:

Alternatively, use FunctionDeclaration to associate the definition of a function with a type specification:

The result is the same:

Scope  (13)

Multiple Definitions  (1)

Several definitions attached to the same symbol can be used:

Compile a function that uses the definitions:

This calls the definition that uses a condition:

This calls the definition that uses a literal 2:

This calls the last catchall definition:

Multiple Declarations  (1)

Definitions attached to a symbol can be used in more than one declaration with different types:

Make two declarations with different types and compile functions that use each:

Call the integer case:

Call the real case:

Polymorphic Declarations  (1)

Definitions attached to a symbol can be declared with a polymorphic type:

Make a polymorphic declaration and compile functions that use it for different types:

Call the integer case:

Call the real case:

Recursive Calls  (1)

Function declarations that use a symbol definition can call themselves:

Make a declaration and compile a function that uses it:

Call the function:

Unnamed Patterns  (1)

A pattern argument does not need a name:

Compile a function that uses the definition:

Call the function with different values:

Repeated Patterns  (1)

If the same name appears more than once in a definition, when called, the value must be the same:

Compile a function that uses the definition:

Call the function with different values:

Call the function with the same value and it uses the definition for the same value:

Matching the Head  (1)

A pattern can be written to match the head:

Make a polymorphic declaration that uses the definition:

Compile a function that uses the declaration with an argument that does not match the head:

Call the function with an integer and that uses the definition that does not match the head:

Compile a function that uses the declaration with an argument that does match the head:

Call the function with a real and that uses the definition that matches the head:

Pattern Test  (1)

Compiled patterns can use PatternTest:

Compile a function that uses the definition:

The input is even:

The input is odd:

Condition  (1)

Compiled patterns can use Condition:

Compile a function that uses the definition:

The input has arguments in order:

The input has arguments not in order, so in the output, they are reversed:

Except  (1)

Compiled patterns can use Except:

Make a declaration and compile a function that uses it:

The argument is even, so the first definition is not used:

The argument is odd, so the first definition is used:

Compile a function that uses the definition:

The argument is even and greater than 20, so the first definition is not used:

The argument is odd and greater than 20, so the first definition is used:

The argument is odd but less than 20, so the first definition is not used:

Alternatives  (1)

Compiled patterns can use Alternatives:

Make a declaration:

Compile a function to use the declaration:

This function matches the input, so a result is generated:

Compile a function with a different type to use the declaration:

This function also matches the input, so a result is generated:

Compound Patterns  (1)

Compilation supports compounds patterns for certain types such as "InertExpression" and "PackedArray":

Compile a function that uses the definition:

This function matches the input so a result is generated:

Compile a function with a different type to use the declaration:

Sequences  (1)

Compilation supports certain sequence patterns for "InertExpression":

Compile a function that uses the definition:

This sequence gets flattened:

The pattern with a sequence does not match, so this returns a failure:

The pattern can have a compound head of any expression type:

This matches:

This does not match:

Applications  (1)

Symbol Definitions  (1)

Declarations that use symbol definitions are useful if the declaration is used more than once:

A FunctionDeclaration that refers to the symbol:

A function that uses the symbol:

Compiled code for the function:

A vector plot based on the data that was created:

The compiled version is much faster:

An animation of the output:

Possible Issues  (5)

Updating  (1)

DownValuesFunction uses the definitions used when the compilation is carried out:

The result uses the definitions in place when the compilation is done:

Definition Restrictions  (1)

If there is no definition that applies to particular arguments, a runtime error case will be added:

This returns a result:

There is no definition that works for this input and hence a runtime error results:

Type Consistency  (1)

All the branches of pattern definitions must return the same type:

All the branches of pattern definitions must compile for the arguments:

This compiles:

This does not compile:

Unsupported Patterns  (1)

Optional patterns are not supported:

Held patterns are not supported:

Verbatim patterns are not supported:

Sequence Patterns  (1)

Sequence patterns do not support polymorphic declarations:

Make a polymorphic declaration, but the compilation cannot use it:

See Also

FunctionCompile  Typed  FunctionDeclaration  DownValues  SetDelayed  KernelEvaluate  KernelFunction

Tech Notes

    ▪
  • Wolfram Compiler Manual

Related Guides

    ▪
  • Code Compilation

History

Introduced in 2022 (13.2) | Updated in 2025 (14.3)

Wolfram Research (2022), DownValuesFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/DownValuesFunction.html (updated 2025).

Text

Wolfram Research (2022), DownValuesFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/DownValuesFunction.html (updated 2025).

CMS

Wolfram Language. 2022. "DownValuesFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/DownValuesFunction.html.

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2025_downvaluesfunction, organization={Wolfram Research}, title={DownValuesFunction}, year={2025}, url={https://reference.wolfram.com/language/ref/DownValuesFunction.html}, note=[Accessed: 01-May-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • 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