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
Set
  • See Also
    • SetDelayed
    • TagSet
    • UpSet
    • Increment
    • Decrement
    • AddTo
    • TimesBy
    • Unset
    • Clear
    • HoldPattern
    • OwnValues
    • Replace
    • Dynamic
    • Setter
  • Related Guides
    • Assignments
    • Procedural Programming
    • Using Connected Devices
    • Defining Variables and Functions
    • Operations on Vectors
    • Language Overview
    • Wolfram Language Syntax
    • Rules & Patterns
    • Scoping Constructs
  • Tech Notes
    • Values for Symbols
    • Making Definitions for Indexed Objects
    • Immediate and Delayed Definitions
    • Variables in Pure Functions and Rules
    • See Also
      • SetDelayed
      • TagSet
      • UpSet
      • Increment
      • Decrement
      • AddTo
      • TimesBy
      • Unset
      • Clear
      • HoldPattern
      • OwnValues
      • Replace
      • Dynamic
      • Setter
    • Related Guides
      • Assignments
      • Procedural Programming
      • Using Connected Devices
      • Defining Variables and Functions
      • Operations on Vectors
      • Language Overview
      • Wolfram Language Syntax
      • Rules & Patterns
      • Scoping Constructs
    • Tech Notes
      • Values for Symbols
      • Making Definitions for Indexed Objects
      • Immediate and Delayed Definitions
      • Variables in Pure Functions and Rules

lhs=rhs

evaluates rhs and assigns the result to be the value of lhs. From then on, lhs is replaced by rhs whenever it appears.

{l1,l2,…}={r1,r2,…}

evaluates the ri, and assigns the results to be the values of the corresponding li.

Details
Details and Options Details and Options
Background & Context
Examples  
Basic Examples  
Scope  
Left-Hand Sides  
Different Kinds of Values  
Generalizations & Extensions  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Tech Notes
Related Guides
Related Links
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • SetDelayed
    • TagSet
    • UpSet
    • Increment
    • Decrement
    • AddTo
    • TimesBy
    • Unset
    • Clear
    • HoldPattern
    • OwnValues
    • Replace
    • Dynamic
    • Setter
  • Related Guides
    • Assignments
    • Procedural Programming
    • Using Connected Devices
    • Defining Variables and Functions
    • Operations on Vectors
    • Language Overview
    • Wolfram Language Syntax
    • Rules & Patterns
    • Scoping Constructs
  • Tech Notes
    • Values for Symbols
    • Making Definitions for Indexed Objects
    • Immediate and Delayed Definitions
    • Variables in Pure Functions and Rules
    • See Also
      • SetDelayed
      • TagSet
      • UpSet
      • Increment
      • Decrement
      • AddTo
      • TimesBy
      • Unset
      • Clear
      • HoldPattern
      • OwnValues
      • Replace
      • Dynamic
      • Setter
    • Related Guides
      • Assignments
      • Procedural Programming
      • Using Connected Devices
      • Defining Variables and Functions
      • Operations on Vectors
      • Language Overview
      • Wolfram Language Syntax
      • Rules & Patterns
      • Scoping Constructs
    • Tech Notes
      • Values for Symbols
      • Making Definitions for Indexed Objects
      • Immediate and Delayed Definitions
      • Variables in Pure Functions and Rules

Set

lhs=rhs

evaluates rhs and assigns the result to be the value of lhs. From then on, lhs is replaced by rhs whenever it appears.

{l1,l2,…}={r1,r2,…}

evaluates the ri, and assigns the results to be the values of the corresponding li.

Details

  • lhs can be any expression, including a pattern.
  • f[x_]=x^2 is a typical assignment for a pattern. Notice the presence of _ on the left‐hand side, but not the right‐hand side.
  • An assignment of the form f[args]=rhs sets up a transformation rule associated with the symbol f.
  • Different rules associated with a particular symbol are usually placed in the order that you give them. If a new rule that you give is determined to be more specific than existing rules, it is, however, placed before them. When the rules are used, they are tested in order. »
  • New assignments with identical lhs overwrite old ones. »
  • You can see all the assignments associated with a symbol f using ?f or Definition[f].
  • If you make assignments for functions that have attributes like Flat and Orderless, you must make sure to set these attributes before you make assignments for the functions.
  • Set has attribute HoldFirst.
  • If lhs is of the form f[args], then args are evaluated. »
  • There are some special functions for which an assignment to s[f[args]] is automatically associated with f rather than s. These functions include: Attributes, Default, Format, MessageName, Messages, N, and Options. »
  • When it appears in an unevaluated symbolic form, Set is treated as a scoping construct so that variables in nested occurrences are renamed if necessary. »
  • lhs=rhs returns rhs even if for some reason the assignment specified cannot be performed.
  • Some global variables such as $RecursionLimit can only be assigned a certain range or class of values.

Background & Context

  • Set is a function that evaluates and assigns an expression to be the value of a variable. The expression Set[lhs,rhs] is commonly represented using the shorthand syntax lhs=rhs. After Set is evaluated, lhs is replaced by rhs whenever it appears. Depending on the form of lhs, the result is stored as in the associated OwnValues, DownValues, or a specialized data structure.
  • Set often contains patterns on the lhs that are assigned transformed values as indicated on the rhs, e.g. f[x_] = x^2. lhs=rhs evaluates rhs immediately, so in situations where rhs should be evaluated only after the assignment is made, SetDelayed (written in shorthand as :=) should be used instead.
  • The assignments associated with a given symbol can be seen using Definition[f]. Individual assignments may be removed from a symbol using Unset; Clear and ClearAll remove all definitions at once.

Examples

open all close all

Basic Examples  (2)

Set a value for :

Unset :

Set multiple values:

Scope  (15)

Left-Hand Sides  (7)

Ordinary program variables:

Set values for "indexed variables":

Define a function from an expression:

Use Block to temporarily set variables:

Set part of a list:

Set part of an expression:

Replace a row of a matrix:

Replace a column of a matrix:

Different Kinds of Values  (8)

Ownvalues:

Downvalues:

Subvalues:

Upvalues:

Default values and options:

Numerical values:

Format values:

A definition for Attributes is associated with , rather than Attributes:

Generalizations & Extensions  (5)

Set and to the same value:

Set and to different values:

Interchange values:

Set part of a sparse array:

v is still a sparse array, with its second part changed:

Assign multiple return values of a function to individual variables:

A definition for a pattern with a specific head is associated with that head:

Applications  (6)

Compute the GCD of two numbers:

Find a fixed point:

Compute using Newton's method:

Use a variable as an abbreviation for a complicated expression used more than once:

A scalar implementation of backsubstitution in a system of linear equations:

A vector implementation of backsubstitution in a system of linear equations:

Properties & Relations  (9)

The right side of an immediate definition is evaluated when the definition is made:

The right side of a delayed definition is evaluated each time the definition is used:

The arguments of the left side of a definition are evaluated before the definition is made:

Definitions with the same left side overwrite earlier ones:

Make definitions for special and general cases using immediate and delayed assignments:

More specific definitions are put in front of more general ones:

The pattern variable is renamed if necessary inside a nested scope:

Module introduces new symbols, distinct from global ones:

Definition prints definitions associated with a symbol:

Information prints various information about a symbol, including any definitions:

OwnValues returns a list of rules corresponding to any downvalues defined:

Use Unset (=.) to clear definitions with a particular left-hand side:

Clear all definitions:

Possible Issues  (4)

In the presence of global variables, pattern variables may show unexpected behavior:

Delayed assignments behave as expected:

Runaway definitions:

Pattern variables are not symbols; you cannot normally assign to them:

Use local variables for this purpose:

Use upvalues to assign to subscripted variables:

Subscripted variables are distinct from indexed variables:

Neat Examples  (1)

Compute the arithmetic-geometric mean of two numbers [more info]:

See Also

SetDelayed  TagSet  UpSet  Increment  Decrement  AddTo  TimesBy  Unset  Clear  HoldPattern  OwnValues  Replace  Dynamic  Setter

Function Repository: SetTo  SetUnless  SetByRules

Tech Notes

    ▪
  • Values for Symbols
  • ▪
  • Making Definitions for Indexed Objects
  • ▪
  • Immediate and Delayed Definitions
  • ▪
  • Variables in Pure Functions and Rules

Related Guides

    ▪
  • Assignments
  • ▪
  • Procedural Programming
  • ▪
  • Using Connected Devices
  • ▪
  • Defining Variables and Functions
  • ▪
  • Operations on Vectors
  • ▪
  • Language Overview
  • ▪
  • Wolfram Language Syntax
  • ▪
  • Rules & Patterns
  • ▪
  • Scoping Constructs

Related Links

  • Fast Introduction for Programmers: Assignments
  • Fast Introduction for Programmers: Function Definitions
  • An Elementary Introduction to the Wolfram Language : Immediate and Delayed Values

History

Introduced in 1988 (1.0)

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

Text

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

CMS

Wolfram Language. 1988. "Set." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Set.html.

APA

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

BibTeX

@misc{reference.wolfram_2025_set, author="Wolfram Research", title="{Set}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Set.html}", note=[Accessed: 04-February-2026]}

BibLaTeX

@online{reference.wolfram_2025_set, organization={Wolfram Research}, title={Set}, year={1988}, url={https://reference.wolfram.com/language/ref/Set.html}, note=[Accessed: 04-February-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