The Wolfram Language
A fast introduction for programmers about the Wolfram language.
2+2
Range[10]
NestList[f,x,5]
List[a,b,c]
Plus[2,2]
Plus[Power[x,2],Times[3,Power[y,3]]]
ed=Graphics3D[Sphere[]]
EdgeDetect[%]
x
ed=Graphics3D[Sphere[]]
ed
{3, 4, 5, 7/8, x, y,
x^2 + 3 y^3, {a, b,
c}, [\!\(\*Graphics3DBox[SphereBox[{0, 0, 0}],
ImageSize -> {46.62109375, Automatic},
ViewPoint -> {1.3423934952878664`, -2.404165276254038,
1.9667152890703756`},
ViewVertical -> {0.009348068236588528, -0.008691644947737727,
0.9999185311455862}]\)]}
{3, 4, 5, 7/8, x, y,
x^2 + 3 y^3, {a, b,
c}, ed}
{a, b, c, d}[[3]]
{a, b, c, d, e, f}[[-3]]
{1, 2, 3} + 2
{a, b, c} + {x, y, z}
{a, b, c, d, e, f}[[2 ;; 4]]
Table[x^2, {x, 10}]
Table[f[x], {x, 4, 20, 2}]
Table[f[x], {x, {5, 10, 20, 10, 5}}]
Table[i/j,{i,4},{j,2}]
x = 7
t := Now
t
t
x =.
t =.
Module[{a = 1}, a + 8]
Cases[{f[1], g[2], f[5], g[3]}, f[_]]
Replace[f[100], f[x_] -> x + 5]
{f[1], g[2], f[5], g[3]} /. f[x_] -> x + 5
Cases[{f[1, 2], f[1], g[3]}, f[__]]
Cases[{f[1], g[2], f[2], f[5], g[3]}, f[1 | 5]]
Cases[{f[1], g[2], f[2], f[5], g[3]}, (f | g)[2]]
Cases[{1, 2.5, 3.5, 4}, _Real]
*In[n] and Out[n] label successive inputs and outputs. You can refer to the most recent output as %—though it's usually better to define a variable.
*Arguments to functions are always separated by commas.
*Everything in the Wolfram Language is a symbolic expression.
numbers strings images arrays graphs formulas documents interfaces code ...
*All symbolic expressions have the same fundamental structure: head[arguments]
*The argument to a function can be any symbolic expression:
FullForm always shows the underlying structure.Head always gives the head of an expression; Length gives the number of arguments.
*It's conventional to start variable names with lowercase letters, reserving capitals for built-in objects: