Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pipes Inside Mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45673] Re: Pipes Inside Mathematica?
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Mon, 19 Jan 2004 05:15:17 -0500 (EST)
  • References: <bua3rl$ipr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

{5*Pi, 13*E} // IntegerPart // Table[0, {#[[1]]}, {#[[2]]}] &


Bob Hanlon

In article <bua3rl$ipr$1 at smc.vnet.net>, Harold.Noffke at wpafb.af.mil (Harold
Noffke) wrote:

<< 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.


  • Prev by Date: Prob compiling MathLink code with Carbon
  • Next by Date: Re: StruveH runtime error
  • Previous by thread: RE: Pipes Inside Mathematica?
  • Next by thread: Re: Pipes Inside Mathematica?