Message Boards Message Boards

7 Replies
0 Total Likes
View groups...
Share this post:

mathematica command

Posted 10 years ago

In a mathematica code...i read the command //Flatten; What is this command?

POSTED BY: Lili88 luca
7 Replies

Actually if you type


into the Documentation center you will get the documentation for the Postfix command:

POSTED BY: David Reiss
Posted 10 years ago

Thank you!!

POSTED BY: Lili88 luca

// 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]
POSTED BY: Udo Krause
Posted 10 years ago

It' s not Flatten(x) or another command. IT'S ONLY //Flatten; in the reference o documentation center there is no explanation. For example what does it mean // ? So, if you want to help me, link specific post for my problem or if you known it explain it. Thanks.

POSTED BY: Lili88 luca

The Documentation Center is your friend.

POSTED BY: David Reiss

See Flatten in the reference.

POSTED BY: Udo Krause
In[1]:= Flatten[{{a, b}, {c, {d}, e}, {f, {g, h}}}]

Out[1]= {a, b, c, d, e, f, g, h}
POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract