MathGroup Archive 1999

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

Search the Archive

Pipes within Mathematica?

  • To: mathgroup at
  • Subject: [mg18123] Pipes within Mathematica?
  • From: simon shannon <sshannon at>
  • Date: Fri, 18 Jun 1999 00:51:34 -0400
  • Organization: dera
  • Sender: owner-wri-mathgroup at

dear all,

   does anyone know of an easy way of piping
within a Mathematica session? say i have an arbitrary
list of data like this:

data = {"slap", "boink", 4, 5.3, Pi};

and some procedures which each take a list as
input, do something sequentially to the input

proc1[x_] := Hash /@ x

proc2[x_] := Split[x, Xor[EvenQ[#1],OddQ[#2]]&]

proc3[x_] := Scan[Print[Length[#]]&, x]

note that proc2 doesn't just apply an operation
to each single element---depending on the input
we get an arbitrary partitioning of its input
(depending on the test we give to Split[]).

so my question is: rather than doing


which generates the entire result list for proc1 before
handing on to proc2, and similarly for proc3,
is there a way of doing what in unix parlance
might be written

proc1 < data | proc2 | proc3

or, indeed, if data were itself a generating process
an even simpler

data | proc1 | proc2 | proc3

there are languages that allow procedures to voluntarily
relinquish control to other processes using suspend() and
resume() type statements; perhaps something like this
is possible using the Catch[] and Throw[] in Mathematica.

   thanks in advance

        simon shannon

  • Prev by Date: LiveGraphics3D: missing geometry
  • Next by Date: Re: Re: A little problem with positive numbers
  • Previous by thread: Re: LiveGraphics3D: missing geometry
  • Next by thread: Re: Pipes within Mathematica?