Skip to content

Function

Function[inner] defines a pure function where inner is evaluated with Slot parameters.

Function[x, inner] defines a pure function where inner is evaluated a single parameter x.

Attributes[Function] := {HoldAll, Protected}

Simple examples

In[1]:= Function[1 + Slot[1]][x]
Out[1]= 1 + x
In[2]:= Function[1 + Slot[1] + 2*Slot[2]][x, y]
Out[2]= 1 + x + 2*y
In[3]:= Function[x, x^2][a]
Out[3]= a^2
In[4]:= Function[x, x^2][a, b]
Out[4]= a^2
In[5]:= Function[x, x^2][x]
Out[5]= x^2
In[6]:= Function[x, x^2][-2]
Out[6]= 4