Skip to content
AgileLogics

Wolfram Language Cheat Sheet

Learn Wolfram Language from the basics →

Basics

Shift + Enter
Evaluate the current notebook cell
f[x, y]
Function call — square brackets, capitalized built-ins
x = 5 / f[x_] := x^2
Immediate assignment / delayed definition
expr;
Semicolon suppresses the output
% / Clear[x]
Last result / remove a value
(* comment *)
Comment (can be nested)
?Plot
Quick help for a function

Numbers

1/3 + 1/6
Exact arithmetic: 1/2
N[Pi, 30]
Numeric value to 30 digits
10/4.
A decimal point makes it approximate: 2.5
Quotient[17, 5] / Mod[17, 5]
Integer division and remainder
Round / Floor / Ceiling
Rounding
Prime[10] / PrimeQ[n] / FactorInteger[n]
Number theory

Lists

{1, 2, 3} / Range[10] / Table[i^2, {i, 5}]
Create lists
list[[1]] / list[[-1]] / list[[2 ;; 4]]
Parts: first, last, span
Length / Total / Mean / Sort / Reverse
Common list functions
{1, 2, 3} + 10
Arithmetic works element-wise: {11, 12, 13}
Select[list, EvenQ]
Keep elements that pass a test
Append / Join / Flatten / Partition
Build and reshape

Functional Programming

#^2 & / x |-> x^2
Pure (anonymous) functions
f /@ {a, b}
Map: {f[a], f[b]}
f @@ {a, b}
Apply: f[a, b]
f @@@ {{a, b}, {c, d}}
Apply at level 1: {f[a, b], f[c, d]}
f @ x / x // f
Prefix and postfix call
Fold[f, x, list] / Nest[f, x, n]
Accumulate / repeat a function

Patterns & Rules

x_ / x_Integer / x__ / x___
Any expression / of a head / 1+ / 0+ items
x_ /; x > 0 / x_?EvenQ
Conditions on patterns
expr /. x -> 3
Replace all: substitute a value
f[n_] :> n^2
Delayed rule (right side evaluated per match)
Cases[list, _Integer]
Elements matching a pattern
MatchQ[expr, pattern]
Test a match

Symbolic Math

Expand / Factor / Simplify / Together / Apart
Rewrite expressions
Solve[x^2 == 4, x]
Exact solutions as rules
NSolve / FindRoot[Cos[x] == x, {x, 1}]
Numeric solutions
D[f, x] / Integrate[f, x]
Derivative / integral
Integrate[f, {x, 0, 1}] / NIntegrate
Definite integral, exact or numeric
Limit / Series / Sum / DSolve
Limits, series, sums, differential equations

Associations & Data

a = <|"x" -> 1, "y" -> 2|>
Association (key-value map)
a["x"] / Lookup[a, "z", 0]
Look up a key, with a default
Keys / Values / KeySort / KeyValueMap
Work with keys and values
Counts[list] / GroupBy[list, f]
Count or group into associations
Import["data.csv", "Dataset", HeaderLines -> 1]
Load a CSV as a Dataset
ds[Select[#age > 30 &], "name"]
Query a Dataset

Plotting & Deployment

Plot[Sin[x], {x, 0, 2 Pi}]
Plot a function
ListPlot / BarChart / Histogram
Plot data
Manipulate[Plot[Sin[a x], {x, 0, 6}], {a, 1, 5}]
Interactive controls
Export["plot.png", graphic]
Save a graphic or data to a file
CloudDeploy[APIFunction[{"n" -> "Integer"}, #n^2 &]]
Deploy a web API
wolframscript -file script.wls
Run a script from the terminal