Wolfram Computation Meets Knowledge

The Wolfram Language:
Fast Introduction for Programmers

Show additional notes for:
All sections 
Get Started

Assignments Video Version

Notes for Java programmers:

Since the Wolfram Language is dynamically typed, you don't need to specify a type when assigning variables.

Values can be assigned using =

In[1]:=
Out[1]=

This is "immediate" assignment.

An alternative is delayed assignment, where the value is recomputed every
time it is needed:

In[2]:=
In[3]:=
Out[3]=

In[4]:=
Out[4]=

Notes for Java programmers:

Java does not have delayed assignments. Achieving similar functionality would require a separate method call for each update.

Notes for Python programmers:

In the Wolfram Language, delayed assignments create variables that dynamically recompute their value every time you use them. Achieving similar functionality in Python would require the use of more complex promise objects.


Clear the assignments:

In[1]:=
In[1]:=

Notes for Java programmers:

Using =. in the Wolfram Language is similar to setting a value to null in Java, but without the risk of NullPointerException.

Notes for Python programmers:

=. in the Wolfram Language works like Python's del operator.


Use Module to localize variables:

In[2]:=
Out[2]=

Notes for Java programmers:

Module introduces scoped variables similar to how methods in Java create locally scoped variables.

Notes for Python programmers:

Functions in Python create locally scoped variables similar to Module in the Wolfram Language.


It's conventional to start variable names with lowercase letters, reserving capitals for built-in objects:

Notes for Java programmers:

In Java, capitalized names specifically represent classes; in the Wolfram Language, capitalized names represent built-in constructs of any kind.

Notes for Python programmers:

In Python naming conventions, capitalized names specifically represent classes; in the Wolfram Language, capitalized names can represent built-in constructs of any kind.


Which of the following will NOT evaluate to 6?


Which of these could be a user-defined variable?


Which of the following clears any assignment for y?

© 2024 Wolfram. All rights reserved.