Pipes Inside Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg45659] Pipes Inside Mathematica?
- From: Harold.Noffke at wpafb.af.mil (Harold Noffke)
- Date: Fri, 16 Jan 2004 19:58:45 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
MathGroup:
I think Mathematica would be a better programming language if it had a
construct that allowed pipes (like Unix does). The //-mark comes
close to facilitating this, but Mathematica needs a placeholder to
denote "result from preceding //-mark".
Here's a short example to illustrate what would be gained.
In[1]:= m = 5*Pi // IntegerPart
Out[1]= 15
In[2]:= n = 13*E // IntegerPart
Out[2]= 35
In[3]:= Table[0, {m}, {n}] // MatrixForm
Out[3]//MatrixForm=
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
> > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
: :
: :
: :
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
What we would really like to write is the preceding computation as a
pipeline, so that it looks something like this ...
{{5*Pi},{13*E}} // IntegerPart // Table[0, Extract[<?>,1],
Extract[<?>,2]] // MatrixForm
The <?> symbol means, "I don't know what to put here" -- it's a
placeholder for whatever Mathematica wants to use as "result from
preceding //-mark". Maybe @ would make a good placeholder here, and
what we would see on screen is ...
{{5*Pi},{13*E}} // IntegerPart // Table[0, Extract[@,1], Extract[@,2]]
// MatrixForm
I think Mathematica will be a better programming language if it adopts
some sort of pipe convention.
Harold