//
is the short form of Postfix. In general Mathematica knows about Prefix
, Infix
and Postfix
. Postfix means the operator or command follows the expression
In[1]:= ?//
Postfix[f[expr]] prints with f[expr] given in default postfix form: expr//f.
Postfix[f[expr],h] prints as exprh. >>
In[2]:= (* Postfix *)
{x1, {x2, {x3, {x4}}, x5, {x6, {x7, {x8}}}}, x9} // Flatten
Out[2]= {x1, x2, x3, x4, x5, x6, x7, x8, x9}
In[3]:= (* Prefix *)
Flatten[{x1, {x2, {x3, {x4}}, x5, {x6, {x7, {x8}}}}, x9}]
Out[3]= {x1, x2, x3, x4, x5, x6, x7, x8, x9}
In[4]:= (* Prefix *)
Flatten @ {x1, {x2, {x3, {x4}}, x5, {x6, {x7, {x8}}}}, x9}
Out[4]= {x1, x2, x3, x4, x5, x6, x7, x8, x9}
start your voyage into Mathematica with an understanding of Evaluation based on the fact that everything is an expression in Mathematica.
One can do
In[7]:= 45 \[Degree] // Cos
Out[7]= 1/Sqrt[2]
In[14]:= 45 ~ Times ~ Degree // Cos
Out[14]= 1/Sqrt[2]
this expression system is based on the fact that there are unary, binary, ternary, .... operators in mathematics. Minus
is an unary operator, Plus
is a n-ary one
In[18]:= 7 ~ Plus ~ (5 // Minus)
Out[18]= 2
In[19]:= 1~Plus~2~Plus~3~Plus~4~Plus~5 == Plus @@ Range[5] == Plus[1, 2, 3, 4, 5]
Out[19]=True