WolframLang: Syntax, Operators Cheatsheet

By Xah Lee. Date: . Last updated: .

WolframLang code can be written in FullForm Syntax or short syntax.

Frequently used functions have short syntax. e.g.

FullFormshort syntax
Plus[3,4]3+4
Rational[3,4]3/4
List[3,4]{3,4}
Equal[x,y]x == y
SameQ[x,y]x === y
Greater[x,y]x > y
Set[x,3]x = 3

This page gives a practically complete list of such short syntax in WolframLang.

Brackets

[]

square brackets are for function arguments. e.g. Sin[Pi]

()

parenthesis are for grouping precedence. e.g. (3+2)*2

{args}

same as List[args]

[see WolframLang: List]

e[[i]]

same as Part[e,i]

[see WolframLang: Get Parts of List]

\[Name]

represent a special character, such as \[Pi] (π), \[Element] (∈), etc.

[see WolframLang: Source Code Encoding and Unicode]

(*blab*)

Comment. Can be nested. Can be multi-line.

"abc"

double quote is for string delimiter. e.g. "abc"

Symbol Name

Aaa

builtin function or other Symbol names begin with capital letter. e.g. Sin[Pi]

$Aaa

builtin variable names begin with $. e.g. $System, $Version, $ProcessorCount

a`b

grave accent mark is context separator for Symbol. (It's a namespace separator. similar to the slash in file path separator, or dot used by golang, python, java.)

x = 3;
Context[x]
(* Global` *)

Global`x
(* 3 *)

Expression Separator

expr1;expr2

same as CompoundExpression[expr1,expr2]

[see WolframLang: CompoundExpression and Semicolon]

Interactive Session

?a

same as Information["a"]

[see WolframLang: List and Find Functions]

%n

same as Out[n]

Out

%

same as Out[-1]

%%

same as Out[-2]. And so on for %%%, etc.

Pure Function

body&

same as Function[body]

[see WolframLang: Function Syntax Shortcut]

x|->body

same as Function[x,body]

#

same as Slot[1]. Use to stand for first parameter of function.

Slot

#n
  • if n is a integer, then same as Slot[n].
  • if n is a name (letter sequence), then same as Slot["name"].
##

same as SlotSequence[]

SlotSequence

##n

same as SlotSequence[n]

Function Application

f@x

prefix notation. same as f[x]

x//f

postfix notation. same as f[x]

a~f~b

infix notation. same as f[a,b]

f/@x

same as Map[f,x]

[see WolframLang: Map Function to List]

f@@x

same as Apply[f,x]

Apply

f@@@x

same as Apply[f,x, {1}].

Function Composition

f@*g

same as Composition[f,g]

Composition

f/*g

same as RightComposition[f,g]

RightComposition

Assignment (Create Rule)

a=b

same as Set[a,b]

[see WolframLang: Set, SetDelayed]

a:=b

same as SetDelayed[a,b]

x//=f

same as ApplyTo[x,f]

ApplyTo

lhs^=rhs

same as UpSet[lhs,rhs]

UpSet

lhs^:=rhs

same as UpSetDelayed[lhs,rhs]

UpSetDelayed

f/:lhs=rhs

same as TagSet[lhs,rhs]

TagSet

f/:lhs:=rhs

same as TagSetDelayed[f,lhs,rhs]

TagSetDelayed

Equality

a==b

same as Equal[a,b]

[see WolframLang: Equality Test]

a!=b

same as Unequal[a,b]

a===b

same as SameQ[a,b]

a=!=b

same as UnsameQ[a,b]

String

a<>b

same as StringJoin[a,b]

[see WolframLang: String Functions]

a~~b

same as StringExpression[a,b]

[see WolframLang: String Expression]

Read/Write File

<<file

same as Get[file]

Get

>>file

same as Put[file]

Put

>>>file

same as PutAppend[file]

PutAppend

Rules

a->b

same as Rule[a,b]

[see WolframLang: Rule, RuleDelayed]

a:>b

same as RuleDelayed[a,b]

a/.b

same as Replace[a,b]

[see WolframLang: Functions that Transform Expression by Rules]

Pattern Matching

_

same as Blank[]

[see WolframLang: Pattern Syntax]

__

same as BlankSequence[]

___

same as BlankNullSequence[]

a_

same as Pattern[a, Blank[]]

a__

same as Pattern[a, BlankSequence[]]

a___

same as Pattern[a, BlankNullSequence[]]

a:b

if a is a Symbol, then it's same as Pattern[a,b]. if a is a pattern, then it's same as Optional[a,b].

p..

same as Repeated[p]

a|b

same as Alternatives[a,b]

p/;t

same as Condition[p,t]

p?t

same as PatternTest[p,t]

Number Literal

digits.digits

approximate number (aka float). e.g. 16.8

base^^digits

integer in specified base. Base up to 36, using English letters after 9. Letter case does not matter.

2^^10 === 2
2^^11 === 3
16^^a === 10
16^^f === 15
16^^ff === 255
36^^a === 10
36^^z === 35
36^^z1 === 1261
base^^digits.digits

approximate number in specified base.

significand*^n

scientific notation (significand * 10^n)

1.2*^2 == 120.
3.2*^-2 == 0.032
base^^significand*^n

scientific notation in specified base (significand * base^n)

number`

machine‐precision approximate number. e.g. 1.23`

number`s

arbitrary‐precision number with precision s.

3.1`20 == 3.1
number``s

arbitrary‐precision number with accuracy s

3.1``20 == 3.1

Arithmetics

a+b

same as Plus[a,b]

-b

same as Times[-1,b]

a*b

same as Times[a,b]

a b

same as Times[a,b] if a and b are numbers or symbols.

a/b
  • same as Rational[a,b] If a,b are integers
  • same as Times[a, Power[b, -1]].
a^b

same as Power[a,b]

Logic, Boolean

a&&b

same as And[a,b]

[see WolframLang: True, False (boolean)]

a||b

same as Or[a,b]

!a

same as Not[a]

Misc

symbol::tag

same as MessageName[symbol,tag]

MessageName

x \[Element] dom

same as Element[x,dom]

\[Element] is rendered as

Element

x \[Distributed] dist

same as Distributed[x,dist]

Distributed

a \[UndirectedEdge] b

same as UndirectedEdge[a,b]

UndirectedEdge

a \[DirectedEdge] b

same as DirectedEdge[a,b]

DirectedEdge

Example: FullForm vs Short Syntax

WolframLang: FullForm vs Short Syntax Example

WolframLang Syntax